@dudousxd/nestjs-agent-react 0.9.0 → 0.11.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 +44 -2
- package/dist/index.cjs +633 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +290 -10
- package/dist/index.d.ts +290 -10
- package/dist/index.js +612 -70
- 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, ToolUIPart, DynamicToolUIPart, DataUIPart, UIDataTypes } from 'ai';
|
|
3
3
|
import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
|
|
4
|
-
import { StoredMessage, ThreadSummary, SkillCatalogEntry, ThreadDetail, MessageAttachment, QuotaView } from '@dudousxd/nestjs-agent-core';
|
|
4
|
+
import { StoredMessage, ThreadSummary, SkillCatalogEntry, ToolCatalogEntry, ThreadDetail, MessageAttachment, QuotaView, ToolPresentation, ToolResultField, ToolResultView, ToolPresentationTone } from '@dudousxd/nestjs-agent-core';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
/** Identity surfaced by the backend's `meta` SSE frame / response headers. */
|
|
@@ -74,6 +74,8 @@ interface AgentChatTransportOptions {
|
|
|
74
74
|
* - `ui` → `data-ui` part, `id` = the component id (a repeat id updates it in place)
|
|
75
75
|
* - `approval-requested` → `data-approval-requested` part keyed by the call id, plus the SDK's
|
|
76
76
|
* native `tool-approval-request` (the part moves to `approval-requested`)
|
|
77
|
+
* - `approval-settled` → `data-approval-settled` part keyed by the call id (who decided, through
|
|
78
|
+
* what, remembered or not); the outcome still rides the call's own output
|
|
77
79
|
* - `title`, `cancelled` → transient `data-title` / `data-cancelled` (never stored on the message)
|
|
78
80
|
* - any other kind → `data-<kind>` part carrying the frame minus `kind`, keyed by its `id`
|
|
79
81
|
* when it has one — forwarded, never dropped
|
|
@@ -211,6 +213,12 @@ declare class AgentClient {
|
|
|
211
213
|
* one conversation; omitted, the server reads it as a brand-new thread.
|
|
212
214
|
*/
|
|
213
215
|
listSkills(threadId?: string): Promise<SkillCatalogEntry[]>;
|
|
216
|
+
/**
|
|
217
|
+
* The tools this caller can reach through `agent` (the default agent when omitted), each with the
|
|
218
|
+
* server-declared `presentation` a chat narrates it by — the same list the model is offered.
|
|
219
|
+
* Prefer {@link useToolCatalog}, which fetches it once and shares it.
|
|
220
|
+
*/
|
|
221
|
+
listTools(agent?: string): Promise<ToolCatalogEntry[]>;
|
|
214
222
|
getThread(id: string): Promise<ThreadDetail>;
|
|
215
223
|
deleteThread(id: string): Promise<void>;
|
|
216
224
|
forkFromMessage(threadId: string, messageId: string): Promise<ThreadSummary>;
|
|
@@ -227,12 +235,19 @@ declare class AgentClient {
|
|
|
227
235
|
truncateFromMessage(threadId: string, messageId: string): Promise<OkResult>;
|
|
228
236
|
getQuotaToday(): Promise<QuotaToday>;
|
|
229
237
|
cancelStream(runId: string): Promise<CancelResult>;
|
|
238
|
+
/**
|
|
239
|
+
* `remember` approves later calls of the same tool in the same thread; `via` names the surface
|
|
240
|
+
* the decision came through (the server records `'web'` when omitted).
|
|
241
|
+
*/
|
|
230
242
|
approveToolCall(input: {
|
|
231
243
|
toolCallId: string;
|
|
244
|
+
remember?: boolean;
|
|
245
|
+
via?: string;
|
|
232
246
|
}): Promise<void>;
|
|
233
247
|
rejectToolCall(input: {
|
|
234
248
|
toolCallId: string;
|
|
235
249
|
reason?: string;
|
|
250
|
+
via?: string;
|
|
236
251
|
}): Promise<void>;
|
|
237
252
|
/**
|
|
238
253
|
* Settle a parked question set. `answers` is questionId → chosen option values; a question left
|
|
@@ -299,6 +314,172 @@ interface ChatInputProps {
|
|
|
299
314
|
*/
|
|
300
315
|
declare function ChatInput({ onSubmit, disabled, placeholder, rows, enableSpeech, speechLang, sendLabel, onStop, isStreaming, stopLabel, className, textareaClassName, sendButtonClassName, micButtonClassName, stopButtonClassName, renderMic, }: ChatInputProps): React.JSX.Element;
|
|
301
316
|
|
|
317
|
+
/** Tool name → how the server said it is spoken about. */
|
|
318
|
+
type ToolCatalog = Record<string, ToolPresentation>;
|
|
319
|
+
/** Index `GET <base>/tools` by tool name, keeping only the tools that declared a presentation. */
|
|
320
|
+
declare function toolCatalogFrom(entries: readonly ToolCatalogEntry[]): ToolCatalog;
|
|
321
|
+
/** Dotted-path read. `undefined` rather than a throw, so a template can outlive a field. */
|
|
322
|
+
declare function readPath(value: unknown, path: string): unknown;
|
|
323
|
+
/**
|
|
324
|
+
* Fill `{dotted.path}` placeholders from `context`. A placeholder with nothing behind it collapses
|
|
325
|
+
* along with the whitespace in front of it, so "Reading {key}" degrades to "Reading" rather than
|
|
326
|
+
* printing braces at a person; a filled one keeps the whitespace the author wrote ("({n} files)").
|
|
327
|
+
*/
|
|
328
|
+
declare function fillTemplate(template: string, context: unknown): string;
|
|
329
|
+
/**
|
|
330
|
+
* The sentence for one call: the presentation's `running` or `done` template over the call's input.
|
|
331
|
+
*
|
|
332
|
+
* Nothing here reads the tool's name. A tool the catalog does not describe — added since the catalog
|
|
333
|
+
* loaded, or declared without a presentation — is narrated generically (`fallback`), because the only
|
|
334
|
+
* other thing available to say is its identifier.
|
|
335
|
+
*/
|
|
336
|
+
declare function phraseFor(presentation: ToolPresentation | undefined, input: unknown, isSettled: boolean, fallback?: {
|
|
337
|
+
running: string;
|
|
338
|
+
done: string;
|
|
339
|
+
}): string;
|
|
340
|
+
|
|
341
|
+
/** One labelled reading of a `metrics` view. */
|
|
342
|
+
interface ResolvedReading {
|
|
343
|
+
label: string;
|
|
344
|
+
/** The value as text (`—` for nothing). */
|
|
345
|
+
value: string;
|
|
346
|
+
unit: string | null;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* A tool's output resolved through its view into plain data a renderer draws — never the payload
|
|
350
|
+
* itself. `null` from {@link resolveResultView} means "draw nothing".
|
|
351
|
+
*/
|
|
352
|
+
type ResolvedResultView = {
|
|
353
|
+
kind: 'metrics';
|
|
354
|
+
readings: ResolvedReading[];
|
|
355
|
+
} | {
|
|
356
|
+
kind: 'table';
|
|
357
|
+
columns: ToolResultField[];
|
|
358
|
+
rows: string[][];
|
|
359
|
+
empty: string | null;
|
|
360
|
+
} | {
|
|
361
|
+
kind: 'log';
|
|
362
|
+
lines: string[];
|
|
363
|
+
} | {
|
|
364
|
+
kind: 'note';
|
|
365
|
+
text: string;
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* A view for an output whose tool declared none, from its shape: an array of flat records is a
|
|
369
|
+
* table, an array of strings a log, a flat record a set of readings. `undefined` when nothing fits —
|
|
370
|
+
* a serialized payload is what a person-facing surface exists to avoid, so failing to infer must not
|
|
371
|
+
* fall back to one.
|
|
372
|
+
*/
|
|
373
|
+
declare function inferResultView(output: unknown): ToolResultView | undefined;
|
|
374
|
+
/**
|
|
375
|
+
* Read `output` through `view` (or one inferred from its shape when `view` is omitted and `infer` is
|
|
376
|
+
* on). `null` when there is nothing to draw: an `elsewhere` view, an empty reading set, a missing
|
|
377
|
+
* array. A table whose rows array is present but empty resolves with no rows and its `empty` line.
|
|
378
|
+
*/
|
|
379
|
+
declare function resolveResultView(output: unknown, view: ToolResultView | undefined, options?: {
|
|
380
|
+
infer?: boolean;
|
|
381
|
+
}): ResolvedResultView | null;
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* Where one call stands, as a person reads it:
|
|
385
|
+
* - `running` — input streaming or the tool executing;
|
|
386
|
+
* - `awaiting-approval` — an `action` call parked on a person;
|
|
387
|
+
* - `done` / `failed` / `denied` — settled. A tool that RETURNS `{ error }` has failed just as much
|
|
388
|
+
* as one that threw; the two arrive differently and read the same to a person.
|
|
389
|
+
*/
|
|
390
|
+
type ToolCallStatus = 'running' | 'awaiting-approval' | 'done' | 'failed' | 'denied';
|
|
391
|
+
interface ToolCallState {
|
|
392
|
+
status: ToolCallStatus;
|
|
393
|
+
isSettled: boolean;
|
|
394
|
+
isFailed: boolean;
|
|
395
|
+
isDenied: boolean;
|
|
396
|
+
output: unknown;
|
|
397
|
+
error: string | null;
|
|
398
|
+
}
|
|
399
|
+
/** Whether the stream classified this call as an `action` (it parks for approval before it runs). */
|
|
400
|
+
declare function isActionCall(part: AnyToolUIPart): boolean;
|
|
401
|
+
declare function toolCallState(part: AnyToolUIPart): ToolCallState;
|
|
402
|
+
/**
|
|
403
|
+
* Which failed calls the model went on to correct, by call id: a call that failed and was followed,
|
|
404
|
+
* in the same run, by a SUCCESS of the same tool. The operator wants to know a retry happened, not
|
|
405
|
+
* to read every attempt. A failed read is not corrected by a successful query.
|
|
406
|
+
*/
|
|
407
|
+
declare function correctedCallIds(parts: readonly AnyToolUIPart[]): Set<string>;
|
|
408
|
+
/** Everything a surface needs to talk about one call without naming it. */
|
|
409
|
+
interface ToolCallDescription {
|
|
410
|
+
status: ToolCallStatus;
|
|
411
|
+
/** "Querying orders" / "Queried orders" — or the generic fallback when the tool declared nothing. */
|
|
412
|
+
phrase: string;
|
|
413
|
+
/** The server's noun phrase for the tool; `null` when it declared no presentation. */
|
|
414
|
+
label: string | null;
|
|
415
|
+
icon: string | null;
|
|
416
|
+
tone: ToolPresentationTone;
|
|
417
|
+
detail: string | null;
|
|
418
|
+
/** The approval prompt, templated over the call's input; `null` when the tool declared none. */
|
|
419
|
+
confirm: {
|
|
420
|
+
title: string;
|
|
421
|
+
verb: string;
|
|
422
|
+
detail: string | null;
|
|
423
|
+
} | null;
|
|
424
|
+
/** The output read through its view, once the call is `done`; `null` otherwise or when nothing to draw. */
|
|
425
|
+
result: ResolvedResultView | null;
|
|
426
|
+
error: string | null;
|
|
427
|
+
presentation: ToolPresentation | null;
|
|
428
|
+
}
|
|
429
|
+
interface DescribeToolCallOptions {
|
|
430
|
+
/** Words for a tool the catalog does not describe. Default `Working` / `Done`. */
|
|
431
|
+
fallback?: {
|
|
432
|
+
running: string;
|
|
433
|
+
done: string;
|
|
434
|
+
};
|
|
435
|
+
/** Infer a result view from the output's shape when the tool declared none. Default `false`. */
|
|
436
|
+
inferResult?: boolean;
|
|
437
|
+
}
|
|
438
|
+
declare function describeToolCall(part: AnyToolUIPart, catalog: ToolCatalog | undefined, options?: DescribeToolCallOptions): ToolCallDescription;
|
|
439
|
+
/**
|
|
440
|
+
* Calls folded under one key — "Database query ×3" — with the state that matters most across them.
|
|
441
|
+
*/
|
|
442
|
+
interface ToolActivityGroup {
|
|
443
|
+
key: string;
|
|
444
|
+
/** The server's label for the group's tool; `null` when it declared no presentation. */
|
|
445
|
+
label: string | null;
|
|
446
|
+
icon: string | null;
|
|
447
|
+
/** Worst-first across the calls: running › awaiting-approval › failed › denied › done. */
|
|
448
|
+
status: ToolCallStatus;
|
|
449
|
+
count: number;
|
|
450
|
+
/** The phrase of the group's LATEST call — what is happening now. */
|
|
451
|
+
phrase: string;
|
|
452
|
+
calls: TranscriptToolCall[];
|
|
453
|
+
/** Calls nested under the group's calls (all depths), when nesting was not expanded. */
|
|
454
|
+
innerCount: number;
|
|
455
|
+
}
|
|
456
|
+
interface GroupToolActivityOptions {
|
|
457
|
+
catalog?: ToolCatalog;
|
|
458
|
+
/**
|
|
459
|
+
* What makes two calls "the same activity". Default: the tool's presentation `label`, else its
|
|
460
|
+
* name. Flippy-style source grouping passes its own (e.g. `github:search`).
|
|
461
|
+
*/
|
|
462
|
+
keyOf?: (call: TranscriptToolCall, presentation: ToolPresentation | undefined) => string;
|
|
463
|
+
/**
|
|
464
|
+
* Replace a call that has nested calls with those calls (recursively), so the activity reads as
|
|
465
|
+
* what the code-mode run DID rather than "ran code". Default `false`: groups are built over the
|
|
466
|
+
* top-level calls, and `innerCount` says how much ran beneath them.
|
|
467
|
+
*/
|
|
468
|
+
expandNested?: boolean;
|
|
469
|
+
/** Drop failed calls the model corrected with a later success of the same tool. Default `false`. */
|
|
470
|
+
hideCorrected?: boolean;
|
|
471
|
+
fallback?: {
|
|
472
|
+
running: string;
|
|
473
|
+
done: string;
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* Fold a tool run into activity groups, in order of first appearance. Pass `block.roots` (the
|
|
478
|
+
* transcript's call tree) so nesting is honoured; a flat `block.calls` works too and simply has
|
|
479
|
+
* nothing nested.
|
|
480
|
+
*/
|
|
481
|
+
declare function groupToolActivity(calls: readonly TranscriptToolCall[], options?: GroupToolActivityOptions): ToolActivityGroup[];
|
|
482
|
+
|
|
302
483
|
/** A tool UI part on a `UIMessage` — a static `tool-*` part or the `dynamic-tool` part. */
|
|
303
484
|
type AnyToolUIPart = ToolUIPart | DynamicToolUIPart;
|
|
304
485
|
type ChatStatus = 'ready' | 'submitted' | 'streaming' | 'error';
|
|
@@ -368,16 +549,38 @@ interface TranscriptSettleState {
|
|
|
368
549
|
isSubmitting: boolean;
|
|
369
550
|
run: () => void;
|
|
370
551
|
}
|
|
552
|
+
/** How an approval stands. */
|
|
553
|
+
type TranscriptApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired';
|
|
371
554
|
/**
|
|
372
|
-
* Who has to settle a parked call,
|
|
555
|
+
* Who has to settle a parked call, until when, and — once it settled — how. From the stream's
|
|
556
|
+
* `approval-requested` / `approval-settled` frames, or the same parts a reloaded thread carries.
|
|
373
557
|
* `null` on a call whose runner never said (the call can still be awaiting approval).
|
|
374
558
|
*/
|
|
375
559
|
interface TranscriptApproval {
|
|
376
560
|
/** Open vocabulary the host defines: `'requester'`, `'admin'`, a role… */
|
|
377
561
|
approver: string;
|
|
378
|
-
/** ISO-8601; `null` when the request never lapses. */
|
|
562
|
+
/** ISO-8601; `null` when the request never lapses. Pair with `useApprovalCountdown`. */
|
|
379
563
|
expiresAt: string | null;
|
|
564
|
+
/** Why the call needs a person, when the runner said. */
|
|
380
565
|
reason: string | null;
|
|
566
|
+
/**
|
|
567
|
+
* `pending` until a settlement arrives; then what it said. Falls back to the call's own state
|
|
568
|
+
* (denied → `rejected`, an output → `approved`) for a runner that streams no settlement.
|
|
569
|
+
*/
|
|
570
|
+
status: TranscriptApprovalStatus;
|
|
571
|
+
/** The approval also covers later calls of this tool in this thread. */
|
|
572
|
+
remember: boolean;
|
|
573
|
+
/** Opaque ref of who decided; `null` while pending, on an expiry, or when the runner did not say. */
|
|
574
|
+
decidedBy: string | null;
|
|
575
|
+
/** The surface the decision came through (`'web'`, `'slack'`, `'remembered'`, …). */
|
|
576
|
+
decidedVia: string | null;
|
|
577
|
+
/** What the person said when declining. */
|
|
578
|
+
decisionReason: string | null;
|
|
579
|
+
}
|
|
580
|
+
/** What an approval can carry beyond yes. */
|
|
581
|
+
interface ApproveOptions {
|
|
582
|
+
/** Approve later calls of the same tool in the same thread without asking again. */
|
|
583
|
+
remember?: boolean;
|
|
381
584
|
}
|
|
382
585
|
/** One call in a tool run, with whatever human decision it is parked on. */
|
|
383
586
|
interface TranscriptToolCall {
|
|
@@ -395,13 +598,21 @@ interface TranscriptToolCall {
|
|
|
395
598
|
children: TranscriptToolCall[];
|
|
396
599
|
/** Who has to decide, when the runner said so. See {@link TranscriptApproval}. */
|
|
397
600
|
approval: TranscriptApproval | null;
|
|
601
|
+
/**
|
|
602
|
+
* How to talk about this call without naming it — status, phrase, label, icon, approval prompt,
|
|
603
|
+
* resolved result — from the server's presentation when `toolCatalog` was given, generic otherwise.
|
|
604
|
+
*/
|
|
605
|
+
description: ToolCallDescription;
|
|
398
606
|
/**
|
|
399
607
|
* Parked on a person. An `action` tool's input lands and its output never follows on its own —
|
|
400
608
|
* the loop waits for an approval between the two — so a settled-looking card that never settles
|
|
401
609
|
* IS the pending approval.
|
|
402
610
|
*/
|
|
403
611
|
isAwaitingApproval: boolean;
|
|
404
|
-
|
|
612
|
+
/** `run({ remember: true })` approves this tool for the rest of the thread. */
|
|
613
|
+
approve: TranscriptSettleState & {
|
|
614
|
+
run: (options?: ApproveOptions) => void;
|
|
615
|
+
};
|
|
405
616
|
reject: TranscriptSettleState;
|
|
406
617
|
/** A failed decision — the call is still parked, so the affordance stays live. */
|
|
407
618
|
error: string | null;
|
|
@@ -422,6 +633,11 @@ interface TranscriptToolBlock {
|
|
|
422
633
|
* nested calls in `children`. Equal to `calls` when nothing is nested.
|
|
423
634
|
*/
|
|
424
635
|
roots: TranscriptToolCall[];
|
|
636
|
+
/**
|
|
637
|
+
* The run folded into activity groups ("Database query ×3"), over `roots`, keyed by each tool's
|
|
638
|
+
* presentation label (else its name). For another grouping, call `groupToolActivity` yourself.
|
|
639
|
+
*/
|
|
640
|
+
activity: ToolActivityGroup[];
|
|
425
641
|
}
|
|
426
642
|
/**
|
|
427
643
|
* A component the server pushed into the message (the stream's `ui` frame, or a persisted
|
|
@@ -547,7 +763,7 @@ interface ElicitationBlockOptions {
|
|
|
547
763
|
interface ApprovalBlockOptions {
|
|
548
764
|
canApprove: boolean;
|
|
549
765
|
canReject: boolean;
|
|
550
|
-
approve: (toolCallId: string) => void;
|
|
766
|
+
approve: (toolCallId: string, options?: ApproveOptions) => void;
|
|
551
767
|
reject: (toolCallId: string) => void;
|
|
552
768
|
/** Which decision this call is sending, or `null` for none. */
|
|
553
769
|
submitting: (toolCallId: string) => SettleAction | null;
|
|
@@ -569,6 +785,8 @@ interface BuildBlocksOptions {
|
|
|
569
785
|
elicitation?: ElicitationBlockOptions;
|
|
570
786
|
/** Wire approve/reject onto the calls parked on a human. Omitted → they are reported, not actionable. */
|
|
571
787
|
approval?: ApprovalBlockOptions;
|
|
788
|
+
/** Server-declared tool presentations (`useToolCatalog`), for each call's `description`. */
|
|
789
|
+
toolCatalog?: ToolCatalog;
|
|
572
790
|
}
|
|
573
791
|
/**
|
|
574
792
|
* Walk a message's parts into renderable blocks, buffering consecutive tool parts into one run and
|
|
@@ -703,6 +921,11 @@ interface TranscriptItemOptions {
|
|
|
703
921
|
* run. Off by default, so a renderer already drawing tool cards keeps drawing them.
|
|
704
922
|
*/
|
|
705
923
|
sources?: boolean;
|
|
924
|
+
/**
|
|
925
|
+
* Server-declared tool presentations (`useToolCatalog(...).catalog`). Given → each tool call's
|
|
926
|
+
* `description` and each tool block's `activity` speak in the tool's own words; omitted → generic.
|
|
927
|
+
*/
|
|
928
|
+
toolCatalog?: ToolCatalog;
|
|
706
929
|
/**
|
|
707
930
|
* Settle a parked question set — wire to `useAgentChat`'s `answer`. Supplying it is what lifts a
|
|
708
931
|
* question set out of the tool run into an `elicitation` block: without somewhere to send an
|
|
@@ -715,8 +938,11 @@ interface TranscriptItemOptions {
|
|
|
715
938
|
onAnswer?: (toolCallId: string, answers: Record<string, string[]>) => void | Promise<void>;
|
|
716
939
|
/** Decline the question set and let the agent proceed on its own picks — `useAgentChat`'s `skip`. */
|
|
717
940
|
onSkip?: (toolCallId: string) => void | Promise<void>;
|
|
718
|
-
/**
|
|
719
|
-
|
|
941
|
+
/**
|
|
942
|
+
* Settle a tool call parked on a human — `useAgentChat`'s `approve` / `reject`. `options.remember`
|
|
943
|
+
* is what `call.approve.run({ remember: true })` passed.
|
|
944
|
+
*/
|
|
945
|
+
onApprove?: (toolCallId: string, options?: ApproveOptions) => void | Promise<void>;
|
|
720
946
|
onReject?: (toolCallId: string) => void | Promise<void>;
|
|
721
947
|
}
|
|
722
948
|
interface TranscriptWindow {
|
|
@@ -1157,6 +1383,56 @@ interface ComposerAutocomplete {
|
|
|
1157
1383
|
*/
|
|
1158
1384
|
declare function useComposerAutocomplete(options: UseComposerAutocompleteOptions): ComposerAutocomplete;
|
|
1159
1385
|
|
|
1386
|
+
interface UseToolCatalogOptions {
|
|
1387
|
+
/**
|
|
1388
|
+
* The client to ask — `useAgentChat(...).client`, or one of your own. Must be STABLE across
|
|
1389
|
+
* renders (the shared copy is keyed by it): a client constructed inline refetches every render.
|
|
1390
|
+
*/
|
|
1391
|
+
client: AgentClient;
|
|
1392
|
+
/** The agent whose tools to list. Omitted → the server's default agent. */
|
|
1393
|
+
agent?: string;
|
|
1394
|
+
/** `false` holds the request (e.g. until the user is signed in). Default `true`. */
|
|
1395
|
+
enabled?: boolean;
|
|
1396
|
+
}
|
|
1397
|
+
interface ToolCatalogState {
|
|
1398
|
+
/** Tool name → presentation, for the tools that declared one. `{}` until loaded. */
|
|
1399
|
+
catalog: ToolCatalog;
|
|
1400
|
+
/** Everything `GET <base>/tools` returned, kinds included. */
|
|
1401
|
+
entries: ToolCatalogEntry[];
|
|
1402
|
+
isLoading: boolean;
|
|
1403
|
+
error: Error | null;
|
|
1404
|
+
/** Drop the shared copy and ask again. */
|
|
1405
|
+
refresh: () => void;
|
|
1406
|
+
}
|
|
1407
|
+
/**
|
|
1408
|
+
* The server-declared presentation of the tools this actor can reach (`GET <base>/tools`), for
|
|
1409
|
+
* `phraseFor`, `describeToolCall` and `groupToolActivity` — or pass `catalog` to
|
|
1410
|
+
* `useChatTranscript({ toolCatalog })` and read the phrases off the transcript's calls.
|
|
1411
|
+
*/
|
|
1412
|
+
declare function useToolCatalog(options: UseToolCatalogOptions): ToolCatalogState;
|
|
1413
|
+
|
|
1414
|
+
interface ApprovalCountdown {
|
|
1415
|
+
/** Milliseconds until the request lapses, floored at 0; `null` when it never does. */
|
|
1416
|
+
remainingMs: number | null;
|
|
1417
|
+
/** The instant has passed. Always `false` for a request with no expiry. */
|
|
1418
|
+
isExpired: boolean;
|
|
1419
|
+
}
|
|
1420
|
+
interface UseApprovalCountdownOptions {
|
|
1421
|
+
/** How often the value re-renders while counting. Default 1000 — a seconds label needs no more. */
|
|
1422
|
+
intervalMs?: number;
|
|
1423
|
+
/** Injectable clock for tests. */
|
|
1424
|
+
now?: () => number;
|
|
1425
|
+
}
|
|
1426
|
+
/** What {@link useApprovalCountdown} reads for `expiresAt` at `now`, without the ticking. */
|
|
1427
|
+
declare function approvalCountdown(expiresAt: string | null | undefined, now?: number): ApprovalCountdown;
|
|
1428
|
+
/**
|
|
1429
|
+
* Time left on an approval request (`call.approval.expiresAt`), ticking until it lapses and then
|
|
1430
|
+
* holding at zero. Headless: pair `remainingMs` with `formatElapsed` or any label of your own, and
|
|
1431
|
+
* use `isExpired` to stop offering buttons the server would refuse (`410 Gone`). The server stays
|
|
1432
|
+
* the authority — a lapse is final only once the call settles `expired`.
|
|
1433
|
+
*/
|
|
1434
|
+
declare function useApprovalCountdown(expiresAt: string | null | undefined, options?: UseApprovalCountdownOptions): ApprovalCountdown;
|
|
1435
|
+
|
|
1160
1436
|
/** The thinking time stamped on a reasoning part, or `null` when it carries none. */
|
|
1161
1437
|
declare function readReasoningMs(part: {
|
|
1162
1438
|
providerMetadata?: unknown;
|
|
@@ -1404,12 +1680,16 @@ declare function useAgentChat(options: UseAgentChatOptions): {
|
|
|
1404
1680
|
quota: _dudousxd_nestjs_agent_core.QuotaView | null;
|
|
1405
1681
|
loadQuota: () => Promise<QuotaToday>;
|
|
1406
1682
|
cancel: () => Promise<void>;
|
|
1407
|
-
approve: ({ toolCallId }: {
|
|
1683
|
+
approve: ({ toolCallId, remember, via, }: {
|
|
1408
1684
|
toolCallId: string;
|
|
1685
|
+
/** Approve later calls of the same tool in this thread without asking. */
|
|
1686
|
+
remember?: boolean;
|
|
1687
|
+
via?: string;
|
|
1409
1688
|
}) => Promise<void>;
|
|
1410
|
-
reject: ({ toolCallId, reason, }: {
|
|
1689
|
+
reject: ({ toolCallId, reason, via, }: {
|
|
1411
1690
|
toolCallId: string;
|
|
1412
1691
|
reason?: string;
|
|
1692
|
+
via?: string;
|
|
1413
1693
|
}) => Promise<void>;
|
|
1414
1694
|
answer: ({ toolCallId, answers, }: {
|
|
1415
1695
|
toolCallId: string;
|
|
@@ -1431,4 +1711,4 @@ declare function useAgentChat(options: UseAgentChatOptions): {
|
|
|
1431
1711
|
clearError: () => void;
|
|
1432
1712
|
};
|
|
1433
1713
|
|
|
1434
|
-
export { AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentStreamMeta, type AggregatedTurnUsage, type AnyToolUIPart, type ApprovalBlockOptions, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type BuildBlocksOptions, type CancelResult, type ChatBackground, ChatInput, type ChatInputProps, type ChatStatus, type ChatTranscript, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type ElicitationBlockOptions, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, type MessageUsageInfo, type QuotaToday, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RenderUiFn, type RetrievedPassage, SPEECH_LANGUAGES, type SettleAction, type SkillSuggestionData, type SkillsSourceOptions, type SpeechLanguage, type SpeechRecognitionHook, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type ThreadPatch, type TimestampInfo, type TranscriptActionState, type TranscriptApproval, type TranscriptBlock, type TranscriptCopyState, type TranscriptEditState, type TranscriptElicitationBlock, type TranscriptElicitationOutcome, type TranscriptFile, type TranscriptFilesBlock, type TranscriptItem, type TranscriptItemOptions, type TranscriptQuestion, type TranscriptQuestionOption, type TranscriptReasoningBlock, type TranscriptSettleState, type TranscriptSource, type TranscriptSourcesBlock, type TranscriptStopState, type TranscriptTextBlock, type TranscriptToolBlock, type TranscriptToolCall, type TranscriptUiBlock, type TranscriptWindow, type TriggerMatch, type TriggerPosition, type UsageSummary, type UseAgentChatOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseSpeechRecognitionOptions, type UseTranscriptItemOptions, applyCompletion, backgroundRunsFromThread, buildTranscriptBlocks, createSkillsSource, describeTimestamp, describeUsage, extractMessageText, filterAutocompleteItems, findActiveTrigger, formatElapsed, formatRelativeTime, loadStoredSpeechLang, persistSpeechLang, readReasoningMs, storedMessageToUiMessage, storedThreadToUiMessages, useAgentChat, useChatTranscript, useComposerAutocomplete, useElapsed, useSpeechRecognition, useStickToBottom, useTranscriptItem };
|
|
1714
|
+
export { AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentStreamMeta, type AggregatedTurnUsage, type AnyToolUIPart, type ApprovalBlockOptions, type ApprovalCountdown, type ApproveOptions, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type BuildBlocksOptions, type CancelResult, type ChatBackground, ChatInput, type ChatInputProps, type ChatStatus, type ChatTranscript, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type DescribeToolCallOptions, type ElicitationBlockOptions, type GroupToolActivityOptions, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, type MessageUsageInfo, type QuotaToday, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RenderUiFn, type ResolvedReading, type ResolvedResultView, type RetrievedPassage, SPEECH_LANGUAGES, type SettleAction, type SkillSuggestionData, type SkillsSourceOptions, type SpeechLanguage, type SpeechRecognitionHook, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type ThreadPatch, type TimestampInfo, type ToolActivityGroup, type ToolCallDescription, type ToolCallState, type ToolCallStatus, type ToolCatalog, type ToolCatalogState, type TranscriptActionState, type TranscriptApproval, type TranscriptApprovalStatus, type TranscriptBlock, type TranscriptCopyState, type TranscriptEditState, type TranscriptElicitationBlock, type TranscriptElicitationOutcome, type TranscriptFile, type TranscriptFilesBlock, type TranscriptItem, type TranscriptItemOptions, type TranscriptQuestion, type TranscriptQuestionOption, type TranscriptReasoningBlock, type TranscriptSettleState, type TranscriptSource, type TranscriptSourcesBlock, type TranscriptStopState, type TranscriptTextBlock, type TranscriptToolBlock, type TranscriptToolCall, type TranscriptUiBlock, type TranscriptWindow, type TriggerMatch, type TriggerPosition, type UsageSummary, type UseAgentChatOptions, type UseApprovalCountdownOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseSpeechRecognitionOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, applyCompletion, approvalCountdown, backgroundRunsFromThread, buildTranscriptBlocks, correctedCallIds, createSkillsSource, describeTimestamp, describeToolCall, describeUsage, extractMessageText, fillTemplate, filterAutocompleteItems, findActiveTrigger, formatElapsed, formatRelativeTime, groupToolActivity, inferResultView, isActionCall, loadStoredSpeechLang, persistSpeechLang, phraseFor, readPath, readReasoningMs, resolveResultView, storedMessageToUiMessage, storedThreadToUiMessages, toolCallState, toolCatalogFrom, useAgentChat, useApprovalCountdown, useChatTranscript, useComposerAutocomplete, useElapsed, useSpeechRecognition, useStickToBottom, useToolCatalog, useTranscriptItem };
|