@threadplane/chat 0.0.50 → 0.0.51
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.
|
@@ -1,20 +1,57 @@
|
|
|
1
|
-
import * as _angular_core from '@angular/core';
|
|
2
|
-
import { InjectionToken, Signal, TemplateRef, Type, WritableSignal } from '@angular/core';
|
|
3
1
|
import * as _threadplane_render from '@threadplane/render';
|
|
4
|
-
import {
|
|
5
|
-
export { ViewRegistry, toRenderRegistry, views, withViews, withoutViews } from '@threadplane/render';
|
|
6
|
-
import {
|
|
2
|
+
import { StandardSchemaV1, StandardSchemaInferOutput, AngularRegistry, RenderEvent, ViewRegistry, RenderViewEntry, RenderHost } from '@threadplane/render';
|
|
3
|
+
export { StandardSchemaInferInput, StandardSchemaInferOutput, StandardSchemaV1, ViewRegistry, toRenderRegistry, views, withViews, withoutViews } from '@threadplane/render';
|
|
4
|
+
import { A2uiComponentDef, A2uiSurface, A2uiMessage, A2uiActionMessage } from '@threadplane/a2ui';
|
|
5
|
+
export { A2uiAction, A2uiActionContextEntry, A2uiActionMessage, A2uiChildren, A2uiClientDataModel, A2uiComponent, A2uiComponentDef, A2uiSurface, A2uiTheme, DynamicBoolean, DynamicNumber, DynamicString, isLiteralBoolean, isLiteralNumber, isLiteralString, isPathRef } from '@threadplane/a2ui';
|
|
6
|
+
import * as _angular_core from '@angular/core';
|
|
7
|
+
import { Type, InjectionToken, Signal, TemplateRef, WritableSignal, InputSignal, InputSignalWithTransform } from '@angular/core';
|
|
7
8
|
import * as _json_render_core from '@json-render/core';
|
|
8
9
|
import { StateStore, Spec } from '@json-render/core';
|
|
10
|
+
import { Observable } from 'rxjs';
|
|
9
11
|
import * as _threadplane_chat from '@threadplane/chat';
|
|
10
|
-
import { A2uiComponentDef, A2uiSurface, A2uiMessage, A2uiActionMessage } from '@threadplane/a2ui';
|
|
11
|
-
export { A2uiAction, A2uiActionContextEntry, A2uiActionMessage, A2uiChildren, A2uiClientDataModel, A2uiComponent, A2uiComponentDef, A2uiSurface, A2uiTheme, DynamicBoolean, DynamicNumber, DynamicString, isLiteralBoolean, isLiteralNumber, isLiteralString, isPathRef } from '@threadplane/a2ui';
|
|
12
12
|
import { PartialJsonParser } from '@cacheplane/partial-json';
|
|
13
13
|
import { BaseMessage } from '@langchain/core/messages';
|
|
14
14
|
import * as _cacheplane_partial_markdown from '@cacheplane/partial-markdown';
|
|
15
15
|
import { CitationDefinition, MarkdownDocumentNode, MarkdownNode, MarkdownParagraphNode, MarkdownHeadingNode, MarkdownBlockquoteNode, MarkdownListNode, MarkdownListItemNode, MarkdownCodeBlockNode, MarkdownThematicBreakNode, MarkdownTextNode, MarkdownEmphasisNode, MarkdownStrongNode, MarkdownStrikethroughNode, MarkdownInlineCodeNode, MarkdownLinkNode, MarkdownAutolinkNode, MarkdownImageNode, MarkdownSoftBreakNode, MarkdownHardBreakNode, MarkdownCitationReferenceNode, MarkdownTableNode, MarkdownTableRowNode, MarkdownTableCellNode } from '@cacheplane/partial-markdown';
|
|
16
|
+
import { NavigationExtras } from '@angular/router';
|
|
16
17
|
import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
|
|
17
18
|
|
|
19
|
+
/** Precise authored function tool — what `action()` returns. Carries the schema
|
|
20
|
+
* `S` and the handler's resolved return type `R`. */
|
|
21
|
+
interface FunctionToolDef<S extends StandardSchemaV1 = StandardSchemaV1, R = unknown> {
|
|
22
|
+
readonly kind: 'function';
|
|
23
|
+
readonly description: string;
|
|
24
|
+
readonly schema: S;
|
|
25
|
+
readonly handler: (args: StandardSchemaInferOutput<S>) => R | Promise<R>;
|
|
26
|
+
}
|
|
27
|
+
/** Bivariant union member used only for registry storage/iteration. The handler
|
|
28
|
+
* param is `any` (NOT `never`): `any` is simultaneously a supertype any precise
|
|
29
|
+
* `FunctionToolDef<S,R>` is assignable to under `strictFunctionTypes`, AND
|
|
30
|
+
* callable by internal code that has narrowed by `kind` and parsed runtime args.
|
|
31
|
+
* A `never` param would satisfy the former but break the latter. */
|
|
32
|
+
interface AnyFunctionToolDef {
|
|
33
|
+
readonly kind: 'function';
|
|
34
|
+
readonly description: string;
|
|
35
|
+
readonly schema: StandardSchemaV1;
|
|
36
|
+
readonly handler: (args: any) => unknown | Promise<unknown>;
|
|
37
|
+
}
|
|
38
|
+
interface ViewToolDef<S extends StandardSchemaV1 = StandardSchemaV1, C = unknown> {
|
|
39
|
+
readonly kind: 'view';
|
|
40
|
+
readonly description: string;
|
|
41
|
+
readonly schema: S;
|
|
42
|
+
readonly component: Type<C>;
|
|
43
|
+
}
|
|
44
|
+
interface AskToolDef<S extends StandardSchemaV1 = StandardSchemaV1, C = unknown> {
|
|
45
|
+
readonly kind: 'ask';
|
|
46
|
+
readonly description: string;
|
|
47
|
+
readonly schema: S;
|
|
48
|
+
readonly component: Type<C>;
|
|
49
|
+
}
|
|
50
|
+
/** A client tool the model can call; executed in the browser. */
|
|
51
|
+
type ClientToolDef = AnyFunctionToolDef | ViewToolDef | AskToolDef;
|
|
52
|
+
/** A frozen, name-keyed registry of client tools. */
|
|
53
|
+
type ClientToolRegistry = Readonly<Record<string, ClientToolDef>>;
|
|
54
|
+
|
|
18
55
|
interface ChatConfig {
|
|
19
56
|
/** Shared render registry for consumers that read CHAT_CONFIG. */
|
|
20
57
|
renderRegistry?: AngularRegistry;
|
|
@@ -39,6 +76,46 @@ interface ChatConfig {
|
|
|
39
76
|
__licensePublicKey?: Uint8Array;
|
|
40
77
|
}
|
|
41
78
|
declare const CHAT_CONFIG: InjectionToken<ChatConfig>;
|
|
79
|
+
/**
|
|
80
|
+
* Bootstrap `@threadplane/chat` in an Angular application or standalone
|
|
81
|
+
* component tree.
|
|
82
|
+
*
|
|
83
|
+
* Call this once inside `bootstrapApplication` (or the `providers` array of a
|
|
84
|
+
* root `ApplicationConfig`). It registers the shared {@link ChatConfig} token
|
|
85
|
+
* so every chat component in the tree can read the render registry, avatar
|
|
86
|
+
* label, and assistant display name without explicit prop threading.
|
|
87
|
+
*
|
|
88
|
+
* A license check is fired asynchronously on every call (it never throws; a
|
|
89
|
+
* watermark is shown in non-commercial builds when no valid token is supplied).
|
|
90
|
+
*
|
|
91
|
+
* @param config Options bag that controls the chat feature set:
|
|
92
|
+
* - `renderRegistry` — shared {@link AngularRegistry} wiring tool-view
|
|
93
|
+
* components to their names; pass the value returned by
|
|
94
|
+
* `defineAngularRegistry` from `\@threadplane/render`.
|
|
95
|
+
* - `avatarLabel` — short label shown in the AI avatar bubble (default `"A"`).
|
|
96
|
+
* - `assistantName` — display name shown above assistant messages
|
|
97
|
+
* (default `"Assistant"`).
|
|
98
|
+
* - `license` — signed token from threadplane.ai; omit in development.
|
|
99
|
+
* @returns An `EnvironmentProviders` value suitable for the `providers` array
|
|
100
|
+
* of `bootstrapApplication` or `ApplicationConfig`.
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* // main.ts
|
|
104
|
+
* import { bootstrapApplication } from '@angular/platform-browser';
|
|
105
|
+
* import { provideChat } from '@threadplane/chat';
|
|
106
|
+
* import { defineAngularRegistry, provideRender } from '@threadplane/render';
|
|
107
|
+
* import { DayCardComponent } from './day-card.component';
|
|
108
|
+
*
|
|
109
|
+
* const registry = defineAngularRegistry({ day_card: DayCardComponent });
|
|
110
|
+
*
|
|
111
|
+
* bootstrapApplication(AppComponent, {
|
|
112
|
+
* providers: [
|
|
113
|
+
* provideChat({ renderRegistry: registry, avatarLabel: 'AI' }),
|
|
114
|
+
* provideRender({ registry }),
|
|
115
|
+
* ],
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
42
119
|
declare function provideChat(config: ChatConfig): _angular_core.EnvironmentProviders;
|
|
43
120
|
|
|
44
121
|
type MessageTemplateType = 'human' | 'ai' | 'tool' | 'system' | 'function';
|
|
@@ -166,6 +243,12 @@ interface Subagent {
|
|
|
166
243
|
name?: string;
|
|
167
244
|
status: Signal<SubagentStatus>;
|
|
168
245
|
messages: Signal<Message[]>;
|
|
246
|
+
/**
|
|
247
|
+
* The subagent's own tool calls (name/args/result), referenced by
|
|
248
|
+
* `Message.toolCallIds` in `messages`. Optional: adapters that don't surface
|
|
249
|
+
* subagent tool calls omit it; consumers default to `[]`.
|
|
250
|
+
*/
|
|
251
|
+
toolCalls?: Signal<ToolCall[]>;
|
|
169
252
|
state: Signal<Record<string, unknown>>;
|
|
170
253
|
}
|
|
171
254
|
|
|
@@ -246,6 +329,60 @@ interface ClientToolsCapability {
|
|
|
246
329
|
resolve(toolCallId: string, result: ClientToolResult): void;
|
|
247
330
|
}
|
|
248
331
|
|
|
332
|
+
/**
|
|
333
|
+
* The failure class of an {@link AgentError}, used to drive UI and retry logic:
|
|
334
|
+
*
|
|
335
|
+
* - `connection` — offline / DNS / connection refused / `fetch` failed. Retryable.
|
|
336
|
+
* - `auth` — `401` / `403`; credentials or API key are wrong. Not retryable.
|
|
337
|
+
* - `server` — a `5xx` (retryable) or a non-auth `4xx` like `400`/`404`/`429` (not retryable).
|
|
338
|
+
* - `interrupted` — the stream closed mid-response after a run had started. Retryable.
|
|
339
|
+
* - `aborted` — the user pressed stop; treated as a graceful idle, not surfaced as an error.
|
|
340
|
+
*/
|
|
341
|
+
type AgentErrorKind = 'connection' | 'auth' | 'server' | 'interrupted' | 'aborted';
|
|
342
|
+
/**
|
|
343
|
+
* Structured, classified failure surfaced on `Agent.error`. Extends `Error`, so
|
|
344
|
+
* existing `.message` / `instanceof Error` reads keep working — but adds a
|
|
345
|
+
* machine-readable {@link AgentErrorKind}, a `retryable` flag, an optional HTTP
|
|
346
|
+
* `status`, and the original `cause`.
|
|
347
|
+
*
|
|
348
|
+
* You rarely construct one yourself; adapters normalize raw failures via
|
|
349
|
+
* {@link toAgentError}. Read it off the agent to render legible, cause-specific UI:
|
|
350
|
+
*
|
|
351
|
+
* @example
|
|
352
|
+
* ```ts
|
|
353
|
+
* const err = agent.error(); // AgentError | undefined
|
|
354
|
+
* if (err) {
|
|
355
|
+
* console.warn(err.message); // legible, per-kind copy
|
|
356
|
+
* if (err.kind === 'auth') showApiKeyHelp();
|
|
357
|
+
* if (err.retryable) showRetryButton(); // → agent.retry()
|
|
358
|
+
* }
|
|
359
|
+
* ```
|
|
360
|
+
*/
|
|
361
|
+
declare class AgentError extends Error {
|
|
362
|
+
/** The classified failure type. See {@link AgentErrorKind}. */
|
|
363
|
+
readonly kind: AgentErrorKind;
|
|
364
|
+
/** Whether retrying the same request could plausibly succeed:
|
|
365
|
+
* `connection` | `server` (5xx) | `interrupted` → true; `auth` | `aborted` | non-auth `4xx` → false. */
|
|
366
|
+
readonly retryable: boolean;
|
|
367
|
+
/** The HTTP status code when the failure came from an HTTP response. */
|
|
368
|
+
readonly status?: number;
|
|
369
|
+
/** The original raw error this was classified from, preserved for debugging/telemetry. */
|
|
370
|
+
readonly cause: unknown;
|
|
371
|
+
constructor(init: {
|
|
372
|
+
kind: AgentErrorKind;
|
|
373
|
+
message: string;
|
|
374
|
+
retryable: boolean;
|
|
375
|
+
status?: number;
|
|
376
|
+
cause?: unknown;
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Default, human-facing copy per {@link AgentErrorKind}. Used as the message when
|
|
381
|
+
* a classified error has no better text. Override by mapping `error.kind` to your
|
|
382
|
+
* own strings in a custom error component.
|
|
383
|
+
*/
|
|
384
|
+
declare const AGENT_ERROR_MESSAGES: Record<AgentErrorKind, string>;
|
|
385
|
+
|
|
249
386
|
/**
|
|
250
387
|
* Runtime-neutral contract chat primitives consume.
|
|
251
388
|
*
|
|
@@ -259,15 +396,18 @@ interface ClientToolsCapability {
|
|
|
259
396
|
* Invariant: state lives on signals; `events$` carries only things that are
|
|
260
397
|
* not derivable from signals.
|
|
261
398
|
*/
|
|
262
|
-
interface Agent {
|
|
399
|
+
interface Agent<TState = Record<string, unknown>> {
|
|
263
400
|
messages: Signal<Message[]>;
|
|
264
401
|
status: Signal<AgentStatus>;
|
|
265
402
|
isLoading: Signal<boolean>;
|
|
266
|
-
error: Signal<
|
|
403
|
+
error: Signal<AgentError | undefined>;
|
|
267
404
|
toolCalls: Signal<ToolCall[]>;
|
|
268
|
-
state: Signal<
|
|
405
|
+
state: Signal<TState>;
|
|
269
406
|
submit: (input: AgentSubmitInput, opts?: AgentSubmitOptions) => Promise<void>;
|
|
270
407
|
stop: () => Promise<void>;
|
|
408
|
+
/** Re-run the last submitted input after a failure. No-op if a run is already
|
|
409
|
+
* in flight or there is nothing to retry. Clears `error` and sets loading. */
|
|
410
|
+
retry: () => Promise<void>;
|
|
271
411
|
/**
|
|
272
412
|
* Discards the assistant message at the given index AND all messages after
|
|
273
413
|
* it, then re-runs the agent against the trimmed conversation tail. The
|
|
@@ -285,6 +425,37 @@ interface Agent {
|
|
|
285
425
|
events$: Observable<AgentEvent>;
|
|
286
426
|
}
|
|
287
427
|
|
|
428
|
+
/**
|
|
429
|
+
* Whether `raw` represents an abort (a `DOMException`/`Error` named `AbortError`,
|
|
430
|
+
* or an abort-ish message). Shared by the runtime adapters and {@link toAgentError}
|
|
431
|
+
* so a user-requested stop settles to idle instead of surfacing as an error.
|
|
432
|
+
*
|
|
433
|
+
* @param raw Any thrown/rejected value.
|
|
434
|
+
* @returns `true` if it looks like an abort.
|
|
435
|
+
*/
|
|
436
|
+
declare function isAbortError(raw: unknown): boolean;
|
|
437
|
+
/**
|
|
438
|
+
* Classify any raw error into a structured {@link AgentError}.
|
|
439
|
+
*
|
|
440
|
+
* Resolution order (first match wins): an existing `AgentError` is returned
|
|
441
|
+
* unchanged (idempotent) → a user abort → a structured `status`/`cause.status`
|
|
442
|
+
* → network/connection markers → an HTTP-shaped status in the message → a
|
|
443
|
+
* `server` + retryable fallback. The original error is always preserved on
|
|
444
|
+
* `cause`. Runtime adapters call this before setting `Agent.error`; custom
|
|
445
|
+
* backends can call it too (or throw an `AgentError` directly).
|
|
446
|
+
*
|
|
447
|
+
* @param raw Any thrown/rejected value — an `Error`, a `{ status }` object, a string, etc.
|
|
448
|
+
* @returns The classified {@link AgentError} (kind, retryable, status?, cause).
|
|
449
|
+
* @example
|
|
450
|
+
* ```ts
|
|
451
|
+
* const e = toAgentError(new Error('HTTP 500: Internal Server Error'));
|
|
452
|
+
* e.kind; // 'server'
|
|
453
|
+
* e.retryable; // true
|
|
454
|
+
* e.status; // 500
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
declare function toAgentError(raw: unknown): AgentError;
|
|
458
|
+
|
|
288
459
|
/**
|
|
289
460
|
* Runtime-neutral snapshot of a point in an agent's execution history.
|
|
290
461
|
*
|
|
@@ -308,7 +479,7 @@ interface AgentCheckpoint {
|
|
|
308
479
|
* implement this. Pure request/response runtimes that don't have checkpoints
|
|
309
480
|
* should implement plain Agent.
|
|
310
481
|
*/
|
|
311
|
-
interface AgentWithHistory extends Agent {
|
|
482
|
+
interface AgentWithHistory<TState = Record<string, unknown>> extends Agent<TState> {
|
|
312
483
|
history: Signal<AgentCheckpoint[]>;
|
|
313
484
|
/**
|
|
314
485
|
* Optional reactive map of `messageId → checkpointId`, computed by
|
|
@@ -320,6 +491,27 @@ interface AgentWithHistory extends Agent {
|
|
|
320
491
|
messageCheckpoints?: Signal<ReadonlyMap<string, string>>;
|
|
321
492
|
}
|
|
322
493
|
|
|
494
|
+
/** A typed handle that threads a state shape through Angular DI from
|
|
495
|
+
* `provideAgent(ref, …)` to `injectAgent(ref)` without per-call-site
|
|
496
|
+
* restatement of the generic. */
|
|
497
|
+
interface AgentRef<TState> {
|
|
498
|
+
readonly token: InjectionToken<Agent<TState>>;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Create a typed agent handle.
|
|
502
|
+
*
|
|
503
|
+
* @param debugName Optional name shown in Angular DI error messages.
|
|
504
|
+
* @returns An {@link AgentRef} carrying a state-typed `InjectionToken`.
|
|
505
|
+
* @example
|
|
506
|
+
* ```ts
|
|
507
|
+
* interface TripState { day: number; places: string[]; }
|
|
508
|
+
* export const TRIP = createAgentRef<TripState>('trip');
|
|
509
|
+
* // app.config.ts: provideAgent(TRIP, { assistantId: 'trip' })
|
|
510
|
+
* // component: const agent = injectAgent(TRIP); // LangGraphAgent<TripState>
|
|
511
|
+
* ```
|
|
512
|
+
*/
|
|
513
|
+
declare function createAgentRef<TState>(debugName?: string): AgentRef<TState>;
|
|
514
|
+
|
|
323
515
|
type AgentRuntimeTelemetryEvent = 'ngaf:runtime_instance_created' | 'ngaf:runtime_request_created' | 'ngaf:stream_started' | 'ngaf:stream_ended' | 'ngaf:stream_errored';
|
|
324
516
|
interface AgentRuntimeTelemetryProperties {
|
|
325
517
|
transport: 'langgraph' | 'ag-ui' | 'custom' | string;
|
|
@@ -349,7 +541,7 @@ declare class MessageTemplateDirective {
|
|
|
349
541
|
*/
|
|
350
542
|
declare function getMessageType(message: Message): MessageTemplateType;
|
|
351
543
|
declare class ChatMessageListComponent {
|
|
352
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
544
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
353
545
|
readonly messageTemplates: _angular_core.Signal<readonly MessageTemplateDirective[]>;
|
|
354
546
|
readonly messages: _angular_core.Signal<Message[]>;
|
|
355
547
|
readonly getMessageType: typeof getMessageType;
|
|
@@ -484,7 +676,7 @@ declare class ChatSuggestionsComponent {
|
|
|
484
676
|
*/
|
|
485
677
|
declare function submitMessage(agent: Agent, text: string): string | null;
|
|
486
678
|
declare class ChatInputComponent {
|
|
487
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
679
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
488
680
|
readonly submitOnEnter: _angular_core.InputSignal<boolean>;
|
|
489
681
|
readonly placeholder: _angular_core.InputSignal<string>;
|
|
490
682
|
/** When true (default), shows a stop button while the agent is streaming. */
|
|
@@ -524,7 +716,7 @@ declare class ChatInputComponent {
|
|
|
524
716
|
|
|
525
717
|
declare function isTyping(agent: Agent): boolean;
|
|
526
718
|
declare class ChatTypingIndicatorComponent {
|
|
527
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
719
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
528
720
|
readonly visible: _angular_core.Signal<boolean>;
|
|
529
721
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ChatTypingIndicatorComponent, never>;
|
|
530
722
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ChatTypingIndicatorComponent, "chat-typing-indicator", never, { "agent": { "alias": "agent"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
@@ -620,15 +812,14 @@ declare class ChatScrollBubbleComponent {
|
|
|
620
812
|
|
|
621
813
|
declare function extractErrorMessage(error: unknown): string | null;
|
|
622
814
|
declare class ChatErrorComponent {
|
|
623
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
624
|
-
readonly errorMessage: _angular_core.Signal<string | null>;
|
|
815
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
625
816
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ChatErrorComponent, never>;
|
|
626
817
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ChatErrorComponent, "chat-error", never, { "agent": { "alias": "agent"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
627
818
|
}
|
|
628
819
|
|
|
629
820
|
declare function getInterrupt(agent: Agent): AgentInterrupt | undefined;
|
|
630
821
|
declare class ChatInterruptComponent {
|
|
631
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
822
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
632
823
|
readonly templateRef: _angular_core.Signal<TemplateRef<any> | undefined>;
|
|
633
824
|
readonly interrupt: _angular_core.Signal<AgentInterrupt | undefined>;
|
|
634
825
|
defaultText(i: AgentInterrupt): string;
|
|
@@ -697,7 +888,7 @@ interface Group {
|
|
|
697
888
|
templateRef?: ChatToolCallTemplateDirective;
|
|
698
889
|
}
|
|
699
890
|
declare class ChatToolCallsComponent {
|
|
700
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
891
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
701
892
|
readonly message: _angular_core.InputSignal<Message | undefined>;
|
|
702
893
|
readonly grouping: _angular_core.InputSignal<"auto" | "none">;
|
|
703
894
|
readonly groupSummary: _angular_core.InputSignal<((name: string, count: number) => string) | undefined>;
|
|
@@ -736,7 +927,7 @@ declare class ChatToolCallsComponent {
|
|
|
736
927
|
* (and a `status` a component chooses not to declare) are harmless.
|
|
737
928
|
*/
|
|
738
929
|
declare class ChatToolViewsComponent {
|
|
739
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
930
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
740
931
|
readonly events: _angular_core.OutputEmitterRef<RenderEvent>;
|
|
741
932
|
readonly message: _angular_core.InputSignal<Message | undefined>;
|
|
742
933
|
readonly views: _angular_core.InputSignal<Readonly<Record<string, _angular_core.Type<unknown> | _threadplane_render.RenderViewEntry>> | undefined>;
|
|
@@ -753,7 +944,7 @@ declare class ChatToolViewsComponent {
|
|
|
753
944
|
}
|
|
754
945
|
|
|
755
946
|
declare class ChatSubagentsComponent {
|
|
756
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
947
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
757
948
|
readonly templateRef: _angular_core.Signal<TemplateRef<any> | undefined>;
|
|
758
949
|
readonly activeSubagents: _angular_core.Signal<Subagent[]>;
|
|
759
950
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ChatSubagentsComponent, never>;
|
|
@@ -959,7 +1150,7 @@ declare class ChatGenuiSkeletonComponent {
|
|
|
959
1150
|
}
|
|
960
1151
|
|
|
961
1152
|
declare class ChatTimelineComponent {
|
|
962
|
-
readonly agent: _angular_core.InputSignal<AgentWithHistory
|
|
1153
|
+
readonly agent: _angular_core.InputSignal<AgentWithHistory<Record<string, unknown>>>;
|
|
963
1154
|
readonly checkpointSelected: _angular_core.OutputEmitterRef<AgentCheckpoint>;
|
|
964
1155
|
readonly templateRef: _angular_core.Signal<TemplateRef<any> | undefined>;
|
|
965
1156
|
readonly history: _angular_core.Signal<AgentCheckpoint[]>;
|
|
@@ -1013,14 +1204,17 @@ declare class ChatWelcomeComponent {
|
|
|
1013
1204
|
declare class ChatWelcomeSuggestionComponent {
|
|
1014
1205
|
readonly label: _angular_core.InputSignal<string>;
|
|
1015
1206
|
readonly value: _angular_core.InputSignal<string>;
|
|
1207
|
+
/** Optional short description, surfaced as a hover/focus tooltip on the chip. */
|
|
1208
|
+
readonly description: _angular_core.InputSignal<string | undefined>;
|
|
1016
1209
|
readonly selected: _angular_core.OutputEmitterRef<string>;
|
|
1017
1210
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ChatWelcomeSuggestionComponent, never>;
|
|
1018
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ChatWelcomeSuggestionComponent, "chat-welcome-suggestion", never, { "label": { "alias": "label"; "required": true; "isSignal": true; }; "value": { "alias": "value"; "required": true; "isSignal": true; }; }, { "selected": "selected"; }, never, ["[chatWelcomeSuggestionIcon]"], true, never>;
|
|
1211
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ChatWelcomeSuggestionComponent, "chat-welcome-suggestion", never, { "label": { "alias": "label"; "required": true; "isSignal": true; }; "value": { "alias": "value"; "required": true; "isSignal": true; }; "description": { "alias": "description"; "required": false; "isSignal": true; }; }, { "selected": "selected"; }, never, ["[chatWelcomeSuggestionIcon]"], true, never>;
|
|
1019
1212
|
}
|
|
1020
1213
|
|
|
1021
1214
|
interface ChatSelectOption {
|
|
1022
1215
|
value: string;
|
|
1023
1216
|
label: string;
|
|
1217
|
+
description?: string;
|
|
1024
1218
|
disabled?: boolean;
|
|
1025
1219
|
}
|
|
1026
1220
|
/**
|
|
@@ -1101,6 +1295,35 @@ declare class ChatCitationsCardComponent {
|
|
|
1101
1295
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ChatCitationsCardComponent, "chat-citations-card", never, { "citation": { "alias": "citation"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1102
1296
|
}
|
|
1103
1297
|
|
|
1298
|
+
interface ThreadRoutingConfig {
|
|
1299
|
+
/** The app-owned source-of-truth signal for the active thread id. */
|
|
1300
|
+
threadId: WritableSignal<string | null>;
|
|
1301
|
+
/** Router commands for a thread id (or the bare/welcome path when null).
|
|
1302
|
+
* Default: `(id) => (id ? ['/', id] : ['/'])`. */
|
|
1303
|
+
toCommands?: (id: string | null) => unknown[];
|
|
1304
|
+
/** Extract the thread id from a URL (null = bare). Default: last non-empty path segment. */
|
|
1305
|
+
threadIdFromUrl?: (url: string) => string | null;
|
|
1306
|
+
/** Optional async validity check; on `false` the helper redirects to the bare path
|
|
1307
|
+
* (`replaceUrl: true`). LangGraph apps pass `id => threads.getThread(id).then(Boolean)`. */
|
|
1308
|
+
validate?: (id: string) => Promise<boolean>;
|
|
1309
|
+
/** Extras merged into every navigate (default `{ queryParamsHandling: 'preserve' }`). */
|
|
1310
|
+
navigationExtras?: NavigationExtras;
|
|
1311
|
+
}
|
|
1312
|
+
/**
|
|
1313
|
+
* Bind an app-owned `activeThreadId` signal to the URL — restore on load, stamp on change,
|
|
1314
|
+
* validate-or-redirect, with a bare URL meaning "no thread" (welcome). URL is the source of
|
|
1315
|
+
* truth; nothing is written to localStorage. Must be called in an injection context.
|
|
1316
|
+
*
|
|
1317
|
+
* @example
|
|
1318
|
+
* ```ts
|
|
1319
|
+
* export const ACTIVE_THREAD = signal<string | null>(null);
|
|
1320
|
+
* // providers: provideAgent({ threadId: ACTIVE_THREAD, onThreadId: id => ACTIVE_THREAD.set(id) })
|
|
1321
|
+
* const threads = inject(LangGraphThreadsAdapter);
|
|
1322
|
+
* injectThreadRouting({ threadId: ACTIVE_THREAD, validate: id => threads.getThread(id).then(Boolean) });
|
|
1323
|
+
* ```
|
|
1324
|
+
*/
|
|
1325
|
+
declare function injectThreadRouting(config: ThreadRoutingConfig): void;
|
|
1326
|
+
|
|
1104
1327
|
interface ChatLifecycle {
|
|
1105
1328
|
/** True after `<chat>` initializes with a non-null agent binding. */
|
|
1106
1329
|
readonly componentReady: Signal<boolean>;
|
|
@@ -1214,7 +1437,7 @@ interface ChatRenderEvent {
|
|
|
1214
1437
|
}
|
|
1215
1438
|
|
|
1216
1439
|
declare class ChatComponent {
|
|
1217
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
1440
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
1218
1441
|
readonly views: _angular_core.InputSignal<Readonly<Record<string, _angular_core.Type<unknown> | _threadplane_render.RenderViewEntry>> | undefined>;
|
|
1219
1442
|
/**
|
|
1220
1443
|
* Client-declared tools (`view`/`ask`/`function`) the model may call. When
|
|
@@ -1421,7 +1644,7 @@ declare class ChatComponent {
|
|
|
1421
1644
|
}
|
|
1422
1645
|
|
|
1423
1646
|
declare class ChatPopupComponent {
|
|
1424
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
1647
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
1425
1648
|
/** A2UI component catalog forwarded to the inner <chat>. Without it,
|
|
1426
1649
|
* messages classified as A2UI parse correctly but never mount a
|
|
1427
1650
|
* surface. Pass `a2uiBasicCatalog()` from `@threadplane/chat`. */
|
|
@@ -1461,7 +1684,7 @@ declare class ChatPopupComponent {
|
|
|
1461
1684
|
}
|
|
1462
1685
|
|
|
1463
1686
|
declare class ChatSidebarComponent {
|
|
1464
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
1687
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
1465
1688
|
/** A2UI component catalog forwarded to the inner <chat>. Without it,
|
|
1466
1689
|
* messages classified as A2UI parse correctly but never mount a
|
|
1467
1690
|
* surface. Pass `a2uiBasicCatalog()` from `@threadplane/chat`. */
|
|
@@ -1495,7 +1718,7 @@ declare class ChatSidebarComponent {
|
|
|
1495
1718
|
}
|
|
1496
1719
|
|
|
1497
1720
|
declare class ChatTimelineSliderComponent {
|
|
1498
|
-
readonly agent: _angular_core.InputSignal<AgentWithHistory
|
|
1721
|
+
readonly agent: _angular_core.InputSignal<AgentWithHistory<Record<string, unknown>>>;
|
|
1499
1722
|
readonly selectedIndex: _angular_core.WritableSignal<number>;
|
|
1500
1723
|
readonly history: _angular_core.Signal<AgentCheckpoint[]>;
|
|
1501
1724
|
readonly replayRequested: _angular_core.OutputEmitterRef<string>;
|
|
@@ -1517,7 +1740,7 @@ declare class ChatSidenavComponent {
|
|
|
1517
1740
|
readonly projects: _angular_core.InputSignal<Project[] | null>;
|
|
1518
1741
|
readonly selectedProjectId: _angular_core.InputSignal<string | null>;
|
|
1519
1742
|
readonly projectActions: _angular_core.InputSignal<ProjectActionAdapter | null>;
|
|
1520
|
-
readonly agent: _angular_core.InputSignal<Agent | AgentWithHistory | null>;
|
|
1743
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>> | AgentWithHistory<Record<string, unknown>> | null>;
|
|
1521
1744
|
readonly debug: _angular_core.InputSignal<boolean>;
|
|
1522
1745
|
readonly newChat: _angular_core.OutputEmitterRef<void>;
|
|
1523
1746
|
readonly threadSelected: _angular_core.OutputEmitterRef<string>;
|
|
@@ -1568,7 +1791,7 @@ declare class ChatSidenavScrimComponent {
|
|
|
1568
1791
|
|
|
1569
1792
|
type InterruptAction = 'accept' | 'edit' | 'respond' | 'ignore';
|
|
1570
1793
|
declare class ChatInterruptPanelComponent {
|
|
1571
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
1794
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
1572
1795
|
readonly action: _angular_core.OutputEmitterRef<InterruptAction>;
|
|
1573
1796
|
readonly interrupt: _angular_core.Signal<AgentInterrupt | undefined>;
|
|
1574
1797
|
readonly interruptReason: _angular_core.Signal<string>;
|
|
@@ -1578,7 +1801,7 @@ declare class ChatInterruptPanelComponent {
|
|
|
1578
1801
|
|
|
1579
1802
|
type ChatApprovalAction = 'approve' | 'edit' | 'cancel';
|
|
1580
1803
|
declare class ChatApprovalCardComponent {
|
|
1581
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
1804
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
1582
1805
|
readonly matchKind: _angular_core.InputSignal<string | undefined>;
|
|
1583
1806
|
readonly title: _angular_core.InputSignal<string>;
|
|
1584
1807
|
readonly showEdit: _angular_core.InputSignal<boolean>;
|
|
@@ -1608,7 +1831,9 @@ declare function statusColor(status: SubagentStatus): string;
|
|
|
1608
1831
|
declare class ChatSubagentCardComponent {
|
|
1609
1832
|
readonly subagent: _angular_core.InputSignal<Subagent>;
|
|
1610
1833
|
readonly state: _angular_core.Signal<TraceState>;
|
|
1611
|
-
|
|
1834
|
+
protected textOf(m: Message): string;
|
|
1835
|
+
protected toolCallsFor(m: Message): ToolCall[];
|
|
1836
|
+
protected toToolCallInfo(tc: ToolCall): ToolCallInfo;
|
|
1612
1837
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ChatSubagentCardComponent, never>;
|
|
1613
1838
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ChatSubagentCardComponent, "chat-subagent-card", never, { "subagent": { "alias": "subagent"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1614
1839
|
}
|
|
@@ -2348,37 +2573,164 @@ declare class A2uiVideoComponent {
|
|
|
2348
2573
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<A2uiVideoComponent, "a2ui-video", never, { "url": { "alias": "url"; "required": false; "isSignal": true; }; "autoPlay": { "alias": "autoPlay"; "required": false; "isSignal": true; }; "controls": { "alias": "controls"; "required": false; "isSignal": true; }; "bindings": { "alias": "bindings"; "required": false; "isSignal": true; }; "emit": { "alias": "emit"; "required": false; "isSignal": true; }; "loading": { "alias": "loading"; "required": false; "isSignal": true; }; "childKeys": { "alias": "childKeys"; "required": false; "isSignal": true; }; "spec": { "alias": "spec"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
2349
2574
|
}
|
|
2350
2575
|
|
|
2351
|
-
/**
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
}
|
|
2359
|
-
interface ViewToolDef {
|
|
2360
|
-
readonly kind: 'view';
|
|
2361
|
-
readonly description: string;
|
|
2362
|
-
readonly schema: StandardSchemaV1;
|
|
2363
|
-
readonly component: Type<unknown>;
|
|
2364
|
-
}
|
|
2365
|
-
interface AskToolDef {
|
|
2366
|
-
readonly kind: 'ask';
|
|
2367
|
-
readonly description: string;
|
|
2368
|
-
readonly schema: StandardSchemaV1;
|
|
2369
|
-
readonly component: Type<unknown>;
|
|
2370
|
-
}
|
|
2371
|
-
/** A frozen, name-keyed registry of client tools. */
|
|
2372
|
-
type ClientToolRegistry = Readonly<Record<string, ClientToolDef>>;
|
|
2576
|
+
/**
|
|
2577
|
+
* @internal
|
|
2578
|
+
* Identity mapped type that flattens an object type so editor quick-info shows
|
|
2579
|
+
* the expanded shape instead of a raw conditional/mapped-type expression.
|
|
2580
|
+
*/
|
|
2581
|
+
type Prettify<T> = {
|
|
2582
|
+
[K in keyof T]: T[K];
|
|
2583
|
+
} & {};
|
|
2373
2584
|
|
|
2374
|
-
/**
|
|
2375
|
-
|
|
2376
|
-
/**
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2585
|
+
/** Value type carried by an Angular signal input. */
|
|
2586
|
+
type InputValue<P> = P extends InputSignal<infer T> ? T : P extends InputSignalWithTransform<infer T, infer _U> ? T : never;
|
|
2587
|
+
/** A component instance's declared signal inputs, as a plain prop bag.
|
|
2588
|
+
*
|
|
2589
|
+
* Implementation note: Angular's `InputSignal` and `InputSignalWithTransform`
|
|
2590
|
+
* use `InputSignalNode` in an invariant position, making them invariant in their
|
|
2591
|
+
* type parameters under TypeScript's structural system. `InputSignal<number>`
|
|
2592
|
+
* does NOT extend `InputSignal<unknown>`. We therefore use `any` in the filter
|
|
2593
|
+
* predicate — `any` is a two-way assignability wildcard that correctly subsumes
|
|
2594
|
+
* all concrete instantiations without widening the extracted value type. */
|
|
2595
|
+
type ComponentInputs<C> = {
|
|
2596
|
+
[K in keyof C as C[K] extends InputSignal<any> | InputSignalWithTransform<any, any> ? K : never]: InputValue<C[K]>;
|
|
2597
|
+
};
|
|
2598
|
+
/** STRICT: every prop the schema PRODUCES must be a declared input with an
|
|
2599
|
+
* assignable type. FLEXIBLE: the component may declare extra inputs the schema
|
|
2600
|
+
* doesn't fill. A schema key absent from `Inputs` maps to `never`, so its
|
|
2601
|
+
* (non-never) value fails assignment and the error pins to that prop.
|
|
2602
|
+
*
|
|
2603
|
+
* This mapped type is homomorphic over `keyof Out`, so it preserves the
|
|
2604
|
+
* optionality (`?`) of each schema prop. A consequence: an OPTIONAL schema prop
|
|
2605
|
+
* is accepted against a `required` component input — the compiler cannot know
|
|
2606
|
+
* the model will actually supply it. That residual case (required input not
|
|
2607
|
+
* guaranteed by the schema) is caught at runtime by the schema-readiness mount
|
|
2608
|
+
* gate, which holds the fallback until the streamed props validate. Compile
|
|
2609
|
+
* time blocks structural mismatches; runtime blocks missing-but-required props. */
|
|
2610
|
+
type CompatibleProps<Out, Inputs> = {
|
|
2611
|
+
[K in keyof Out]: K extends keyof Inputs ? Inputs[K] : never;
|
|
2612
|
+
};
|
|
2613
|
+
/** The accepted `component` parameter type for `view`/`ask`: the real component
|
|
2614
|
+
* `Type<C>` when the schema output is compatible, else a labelled error tuple
|
|
2615
|
+
* that surfaces both shapes in the compiler message.
|
|
2616
|
+
*
|
|
2617
|
+
* Implementation note: `C extends ...` (distributive over C) lets TypeScript
|
|
2618
|
+
* infer `C` from the `Type<C>` arm first, then verify the constraint. A bare
|
|
2619
|
+
* conditional on the param type blocks inference when C appears only on the
|
|
2620
|
+
* right-hand side of the inner `extends`. */
|
|
2621
|
+
type AcceptComponent<S extends StandardSchemaV1, C> = C extends (StandardSchemaInferOutput<S> extends CompatibleProps<StandardSchemaInferOutput<S>, ComponentInputs<C>> ? C : never) ? Type<C> : readonly [
|
|
2622
|
+
'Schema output is not assignable to this component\'s inputs',
|
|
2623
|
+
StandardSchemaInferOutput<S>,
|
|
2624
|
+
ComponentInputs<C>
|
|
2625
|
+
];
|
|
2626
|
+
/** Reverse helper: derive a component's input prop types FROM a schema, so a
|
|
2627
|
+
* component authored straight from the schema is guaranteed compatible. */
|
|
2628
|
+
type ViewProps<S extends StandardSchemaV1> = Prettify<StandardSchemaInferOutput<S>>;
|
|
2629
|
+
|
|
2630
|
+
/**
|
|
2631
|
+
* Declare an async function tool the model can call; its resolved return value
|
|
2632
|
+
* becomes the tool result shipped back to the model.
|
|
2633
|
+
*
|
|
2634
|
+
* @param description Natural-language description the model sees.
|
|
2635
|
+
* @param schema Standard Schema (e.g. a Zod object) for the arguments; the
|
|
2636
|
+
* handler's argument type is inferred from it.
|
|
2637
|
+
* @param handler Runs in the browser when the model calls the tool; its return
|
|
2638
|
+
* type `R` is carried on the resulting {@link FunctionToolDef}.
|
|
2639
|
+
* @returns A {@link FunctionToolDef} for inclusion in {@link tools}.
|
|
2640
|
+
* @example
|
|
2641
|
+
* ```ts
|
|
2642
|
+
* const move = action('Move a stop', z.object({ fromDay: z.number() }), (a) => a.fromDay);
|
|
2643
|
+
* const registry = tools({ move_stop: move });
|
|
2644
|
+
* ```
|
|
2645
|
+
*/
|
|
2646
|
+
declare function action<S extends StandardSchemaV1, R>(description: string, schema: S, handler: (args: StandardSchemaInferOutput<S>) => R | Promise<R>): FunctionToolDef<S, R>;
|
|
2647
|
+
/**
|
|
2648
|
+
* Render-only component tool — the model fills the component's props from the
|
|
2649
|
+
* schema's output; the tool call is auto-acknowledged once the component mounts.
|
|
2650
|
+
*
|
|
2651
|
+
* The component's signal inputs are checked against the schema output type
|
|
2652
|
+
* (strict-but-flexible: every schema key must be a declared input with an
|
|
2653
|
+
* assignable type; the component may declare extra inputs the schema doesn't fill).
|
|
2654
|
+
* Author the component with `ViewProps<typeof schema>` as the input type set to
|
|
2655
|
+
* guarantee the shapes stay aligned.
|
|
2656
|
+
*
|
|
2657
|
+
* @param description Natural-language description the model sees.
|
|
2658
|
+
* @param schema Standard Schema defining the props the model must supply.
|
|
2659
|
+
* @param component Angular component whose signal inputs must be compatible with
|
|
2660
|
+
* the schema output. A type-level error is reported here when they diverge.
|
|
2661
|
+
* @returns A {@link ViewToolDef} for inclusion in {@link tools}.
|
|
2662
|
+
* @example
|
|
2663
|
+
* ```ts
|
|
2664
|
+
* const schema = z.object({ label: z.string(), day: z.number() });
|
|
2665
|
+
* type Inputs = ViewProps<typeof schema>; // { label: string; day: number }
|
|
2666
|
+
*
|
|
2667
|
+
* \@Component({ ... })
|
|
2668
|
+
* class DayCardComponent {
|
|
2669
|
+
* label = input.required<string>();
|
|
2670
|
+
* day = input.required<number>();
|
|
2671
|
+
* }
|
|
2672
|
+
*
|
|
2673
|
+
* const dayCard = view('Show a day card', schema, DayCardComponent);
|
|
2674
|
+
* const registry = tools({ day_card: dayCard });
|
|
2675
|
+
* ```
|
|
2676
|
+
*/
|
|
2677
|
+
declare function view<S extends StandardSchemaV1, C>(description: string, schema: S, component: AcceptComponent<S, C>): ViewToolDef<S, C>;
|
|
2678
|
+
/**
|
|
2679
|
+
* Interactive (human-in-the-loop) component tool — the model fills the
|
|
2680
|
+
* component's props from the schema's output; the value the component emits
|
|
2681
|
+
* back to the framework becomes the tool result sent to the model.
|
|
2682
|
+
*
|
|
2683
|
+
* The component's signal inputs are checked against the schema output type
|
|
2684
|
+
* (strict-but-flexible: every schema key must be a declared input with an
|
|
2685
|
+
* assignable type; the component may declare extra inputs the schema doesn't
|
|
2686
|
+
* fill). Author the component with `ViewProps<typeof schema>` to derive input
|
|
2687
|
+
* prop types directly from the schema.
|
|
2688
|
+
*
|
|
2689
|
+
* @param description Natural-language description the model sees.
|
|
2690
|
+
* @param schema Standard Schema defining the props the model must supply.
|
|
2691
|
+
* @param component Angular component whose signal inputs must be compatible with
|
|
2692
|
+
* the schema output. A type-level error is reported here when they diverge.
|
|
2693
|
+
* @returns An {@link AskToolDef} for inclusion in {@link tools}.
|
|
2694
|
+
* @example
|
|
2695
|
+
* ```ts
|
|
2696
|
+
* const schema = z.object({ question: z.string(), options: z.array(z.string()) });
|
|
2697
|
+
* type Inputs = ViewProps<typeof schema>;
|
|
2698
|
+
*
|
|
2699
|
+
* \@Component({ ... })
|
|
2700
|
+
* class ChoiceCardComponent {
|
|
2701
|
+
* question = input.required<string>();
|
|
2702
|
+
* options = input.required<string[]>();
|
|
2703
|
+
* // Emits the chosen option back to the model.
|
|
2704
|
+
* }
|
|
2705
|
+
*
|
|
2706
|
+
* const choice = ask('Ask the user to choose', schema, ChoiceCardComponent);
|
|
2707
|
+
* const registry = tools({ pick_option: choice });
|
|
2708
|
+
* ```
|
|
2709
|
+
*/
|
|
2710
|
+
declare function ask<S extends StandardSchemaV1, C>(description: string, schema: S, component: AcceptComponent<S, C>): AskToolDef<S, C>;
|
|
2711
|
+
/**
|
|
2712
|
+
* Collect named client tools into a frozen, name-keyed registry.
|
|
2713
|
+
*
|
|
2714
|
+
* The overload is generic over the entire map (`const M`) so that each tool's
|
|
2715
|
+
* precise type ({@link FunctionToolDef}`<S,R>`, {@link ViewToolDef}`<S,C>`, or
|
|
2716
|
+
* {@link AskToolDef}`<S,C>`) and every literal key are preserved in the
|
|
2717
|
+
* {@link ClientToolRegistry} passed to `provideChat`. This lets downstream
|
|
2718
|
+
* consumers look up individual tools without losing generic information.
|
|
2719
|
+
*
|
|
2720
|
+
* @param map An object literal mapping tool names to tool definitions created
|
|
2721
|
+
* by {@link action}, {@link view}, or {@link ask}.
|
|
2722
|
+
* @returns A frozen `Readonly<M>` where `M` is the exact inferred map shape.
|
|
2723
|
+
* @example
|
|
2724
|
+
* ```ts
|
|
2725
|
+
* const move = action('Move a stop', z.object({ fromDay: z.number() }), (a) => a.fromDay);
|
|
2726
|
+
* const dayCard = view('Show a day card', z.object({ label: z.string() }), DayCardComponent);
|
|
2727
|
+
*
|
|
2728
|
+
* const registry = tools({ move_stop: move, day_card: dayCard });
|
|
2729
|
+
* // registry.move_stop is FunctionToolDef<...>
|
|
2730
|
+
* // registry.day_card is ViewToolDef<...>
|
|
2731
|
+
* ```
|
|
2732
|
+
*/
|
|
2733
|
+
declare function tools<const M extends Record<string, ClientToolDef>>(map: M): Readonly<M>;
|
|
2382
2734
|
|
|
2383
2735
|
/** Validate raw model args against a Standard Schema. */
|
|
2384
2736
|
declare function validateArgs(schema: StandardSchemaV1, args: unknown): Promise<{
|
|
@@ -2389,7 +2741,7 @@ declare function validateArgs(schema: StandardSchemaV1, args: unknown): Promise<
|
|
|
2389
2741
|
error: string;
|
|
2390
2742
|
}>;
|
|
2391
2743
|
/** Validate args, run the handler, and normalize the outcome to a ClientToolResult. */
|
|
2392
|
-
declare function executeFunctionTool(def:
|
|
2744
|
+
declare function executeFunctionTool(def: AnyFunctionToolDef, rawArgs: unknown): Promise<ClientToolResult>;
|
|
2393
2745
|
|
|
2394
2746
|
/**
|
|
2395
2747
|
* Watches the agent's pending client tool calls and auto-runs FUNCTION tools,
|
|
@@ -2417,7 +2769,7 @@ interface MockAgent extends Agent {
|
|
|
2417
2769
|
messages: WritableSignal<Message[]>;
|
|
2418
2770
|
status: WritableSignal<AgentStatus>;
|
|
2419
2771
|
isLoading: WritableSignal<boolean>;
|
|
2420
|
-
error: WritableSignal<
|
|
2772
|
+
error: WritableSignal<AgentError | undefined>;
|
|
2421
2773
|
toolCalls: WritableSignal<ToolCall[]>;
|
|
2422
2774
|
state: WritableSignal<Record<string, unknown>>;
|
|
2423
2775
|
interrupt?: WritableSignal<AgentInterrupt | undefined>;
|
|
@@ -2454,7 +2806,7 @@ interface MockAgentOptions {
|
|
|
2454
2806
|
messages?: Message[];
|
|
2455
2807
|
status?: AgentStatus;
|
|
2456
2808
|
isLoading?: boolean;
|
|
2457
|
-
error?:
|
|
2809
|
+
error?: AgentError;
|
|
2458
2810
|
toolCalls?: ToolCall[];
|
|
2459
2811
|
state?: Record<string, unknown>;
|
|
2460
2812
|
withInterrupt?: boolean;
|
|
@@ -2464,5 +2816,8 @@ interface MockAgentOptions {
|
|
|
2464
2816
|
}
|
|
2465
2817
|
declare function mockAgent(opts?: MockAgentOptions): MockAgent;
|
|
2466
2818
|
|
|
2467
|
-
|
|
2468
|
-
|
|
2819
|
+
/** Inferred argument type for a schema (alias of StandardSchemaInferOutput). */
|
|
2820
|
+
type ToolArgs<S extends StandardSchemaV1> = StandardSchemaInferOutput<S>;
|
|
2821
|
+
|
|
2822
|
+
export { A2uiAudioPlayerComponent, A2uiButtonComponent, A2uiCardComponent, A2uiCheckBoxComponent, A2uiColumnComponent, A2uiDateTimeInputComponent, A2uiDividerComponent, A2uiIconComponent, A2uiImageComponent, A2uiListComponent, A2uiModalComponent, A2uiMultipleChoiceComponent, A2uiRowComponent, A2uiSliderComponent, A2uiSurfaceComponent, A2uiTabsComponent, A2uiTextComponent, A2uiTextFieldComponent, A2uiVideoComponent, AGENT_ERROR_MESSAGES, AgentError, CHAT_CONFIG, CHAT_LIFECYCLE, CHAT_MARKDOWN_STYLES, ChatApprovalCardComponent, ChatCitationCardTemplateDirective, ChatCitationsCardComponent, ChatCitationsComponent, ChatComponent, ChatConfirmDialogComponent, ChatErrorComponent, ChatGenerativeUiComponent, ChatGenuiSkeletonComponent, ChatHistorySearchPaletteComponent, ChatInputComponent, ChatInterruptComponent, ChatInterruptPanelComponent, ChatLauncherButtonComponent, ChatMessageActionsComponent, ChatMessageComponent, ChatMessageListComponent, ChatOverflowMenuComponent, ChatPopupComponent, ChatProjectListComponent, ChatReasoningComponent, ChatScrollBubbleComponent, ChatSelectComponent, ChatSidebarComponent, ChatSidenavComponent, ChatSidenavScrimComponent, ChatStreamingMdComponent, ChatSubagentCardComponent, ChatSubagentsComponent, ChatSuggestionsComponent, ChatThreadListComponent, ChatTimelineComponent, ChatTimelineSliderComponent, ChatToolCallCardComponent, ChatToolCallTemplateDirective, ChatToolCallsComponent, ChatToolViewsComponent, ChatTraceComponent, ChatTypingIndicatorComponent, ChatWelcomeComponent, ChatWelcomeSuggestionComponent, ChatWindowComponent, CitationsResolverService, ICON_AGENT, ICON_CHECK, ICON_CHEVRON_DOWN, ICON_CHEVRON_UP, ICON_SEND, ICON_TOOL, ICON_WARNING, IS_HEADER_ROW, MARKDOWN_VIEW_REGISTRY, MarkdownAutolinkComponent, MarkdownBlockquoteComponent, MarkdownChildrenComponent, MarkdownCitationReferenceComponent, MarkdownCodeBlockComponent, MarkdownDocumentComponent, MarkdownEmphasisComponent, MarkdownHardBreakComponent, MarkdownHeadingComponent, MarkdownImageComponent, MarkdownInlineCodeComponent, MarkdownLinkComponent, MarkdownListComponent, MarkdownListItemComponent, MarkdownParagraphComponent, MarkdownSoftBreakComponent, MarkdownStrikethroughComponent, MarkdownStrongComponent, MarkdownTableCellComponent, MarkdownTableComponent, MarkdownTableRowComponent, MarkdownTextComponent, MarkdownThematicBreakComponent, MessageTemplateDirective, a2uiBasicCatalog, action, ask, buildA2uiActionMessage, cacheplaneMarkdownViews, createA2uiSurfaceStore, createAgentRef, createClientToolsCoordinator, createContentClassifier, createParseTreeStore, createPartialArgsBridge, deriveJsonSchema, emitBinding, executeFunctionTool, extractErrorMessage, formatDuration, getInterrupt, getMessageType, injectThreadRouting, isAbortError, isAssistantMessage, isSystemMessage, isToolMessage, isTyping, isUserMessage, messageContent, mockAgent, normalizeEnvelopeArgs, normalizeViewEntry, provideChat, renderMarkdown, startClientToolExecutor, statusColor, submitMessage, surfaceToSpec, toAgentError, toClientToolSpecs, tools, validateArgs, view };
|
|
2823
|
+
export type { A2uiComponentView, A2uiSurfaceState, A2uiSurfaceStore, A2uiViewEntry, A2uiViews, Agent, AgentCheckpoint, AgentCustomEvent, AgentErrorKind, AgentEvent, AgentInterrupt, AgentRef, AgentRuntimeTelemetryEvent, AgentRuntimeTelemetryPayload, AgentRuntimeTelemetryProperties, AgentRuntimeTelemetrySink, AgentStateUpdateEvent, AgentStatus, AgentSubmitInput, AgentSubmitOptions, AgentWithHistory, AnyFunctionToolDef, AskToolDef, ChatApprovalAction, ChatConfig, ChatLifecycle, ChatMessageRole, ChatRenderEvent, ChatScrollBubbleMode, ChatSelectOption, ChatSidenavMode, ChatToolCallTemplateContext, Citation, ClientToolDef, ClientToolRegistry, ClientToolResult, ClientToolSpec, ClientToolsCapability, ClientToolsCoordinator, ContentBlock, ContentClassifier, ContentType, ElementAccumulationState, FunctionToolDef, InterruptAction, Message, MessageTemplateType, MockAgent, MockAgentOptions, OverflowMenuItem, ParseTreeStore, PartialArgsBridge, Project, ProjectActionAdapter, ResolvedCitation, Role, Subagent, SubagentStatus, Thread, ThreadActionAdapter, ThreadMatch, ThreadRoutingConfig, ToolArgs, ToolCall, ToolCallInfo, ToolCallStatus, TraceState, ViewProps, ViewToolDef };
|