@threadplane/chat 0.0.50 → 0.0.52
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/fesm2022/threadplane-chat.mjs +701 -120
- package/fesm2022/threadplane-chat.mjs.map +1 -1
- package/package.json +2 -1
- package/types/threadplane-chat.d.ts +560 -85
|
@@ -1,20 +1,63 @@
|
|
|
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
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Application-wide options for {@link provideChat}. Every field is optional;
|
|
57
|
+
* the values are exposed to all chat components in the tree via the
|
|
58
|
+
* `CHAT_CONFIG` injection token, so you set them once at bootstrap instead of
|
|
59
|
+
* threading props through every component.
|
|
60
|
+
*/
|
|
18
61
|
interface ChatConfig {
|
|
19
62
|
/** Shared render registry for consumers that read CHAT_CONFIG. */
|
|
20
63
|
renderRegistry?: AngularRegistry;
|
|
@@ -39,6 +82,46 @@ interface ChatConfig {
|
|
|
39
82
|
__licensePublicKey?: Uint8Array;
|
|
40
83
|
}
|
|
41
84
|
declare const CHAT_CONFIG: InjectionToken<ChatConfig>;
|
|
85
|
+
/**
|
|
86
|
+
* Bootstrap `@threadplane/chat` in an Angular application or standalone
|
|
87
|
+
* component tree.
|
|
88
|
+
*
|
|
89
|
+
* Call this once inside `bootstrapApplication` (or the `providers` array of a
|
|
90
|
+
* root `ApplicationConfig`). It registers the shared {@link ChatConfig} token
|
|
91
|
+
* so every chat component in the tree can read the render registry, avatar
|
|
92
|
+
* label, and assistant display name without explicit prop threading.
|
|
93
|
+
*
|
|
94
|
+
* A license check is fired asynchronously on every call (it never throws; a
|
|
95
|
+
* watermark is shown in non-commercial builds when no valid token is supplied).
|
|
96
|
+
*
|
|
97
|
+
* @param config Options bag that controls the chat feature set:
|
|
98
|
+
* - `renderRegistry` — shared {@link AngularRegistry} wiring tool-view
|
|
99
|
+
* components to their names; pass the value returned by
|
|
100
|
+
* `defineAngularRegistry` from `\@threadplane/render`.
|
|
101
|
+
* - `avatarLabel` — short label shown in the AI avatar bubble (default `"A"`).
|
|
102
|
+
* - `assistantName` — display name shown above assistant messages
|
|
103
|
+
* (default `"Assistant"`).
|
|
104
|
+
* - `license` — signed token from threadplane.ai; omit in development.
|
|
105
|
+
* @returns An `EnvironmentProviders` value suitable for the `providers` array
|
|
106
|
+
* of `bootstrapApplication` or `ApplicationConfig`.
|
|
107
|
+
* @example
|
|
108
|
+
* ```ts
|
|
109
|
+
* // main.ts
|
|
110
|
+
* import { bootstrapApplication } from '@angular/platform-browser';
|
|
111
|
+
* import { provideChat } from '@threadplane/chat';
|
|
112
|
+
* import { defineAngularRegistry, provideRender } from '@threadplane/render';
|
|
113
|
+
* import { DayCardComponent } from './day-card.component';
|
|
114
|
+
*
|
|
115
|
+
* const registry = defineAngularRegistry({ day_card: DayCardComponent });
|
|
116
|
+
*
|
|
117
|
+
* bootstrapApplication(AppComponent, {
|
|
118
|
+
* providers: [
|
|
119
|
+
* provideChat({ renderRegistry: registry, avatarLabel: 'AI' }),
|
|
120
|
+
* provideRender({ registry }),
|
|
121
|
+
* ],
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
42
125
|
declare function provideChat(config: ChatConfig): _angular_core.EnvironmentProviders;
|
|
43
126
|
|
|
44
127
|
type MessageTemplateType = 'human' | 'ai' | 'tool' | 'system' | 'function';
|
|
@@ -121,15 +204,55 @@ interface Message {
|
|
|
121
204
|
*/
|
|
122
205
|
toolCallIds?: string[];
|
|
123
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Type guard narrowing a {@link Message} to `role: 'user'`.
|
|
209
|
+
*
|
|
210
|
+
* @param m The message to test.
|
|
211
|
+
* @returns `true` (and narrows `m`) when the message was sent by the user.
|
|
212
|
+
* @example
|
|
213
|
+
* ```ts
|
|
214
|
+
* const userTurns = agent.messages().filter(isUserMessage);
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
124
217
|
declare function isUserMessage(m: Message): m is Message & {
|
|
125
218
|
role: 'user';
|
|
126
219
|
};
|
|
220
|
+
/**
|
|
221
|
+
* Type guard narrowing a {@link Message} to `role: 'assistant'`.
|
|
222
|
+
*
|
|
223
|
+
* @param m The message to test.
|
|
224
|
+
* @returns `true` (and narrows `m`) when the message came from the assistant.
|
|
225
|
+
* @example
|
|
226
|
+
* ```ts
|
|
227
|
+
* const reply = agent.messages().findLast(isAssistantMessage);
|
|
228
|
+
* ```
|
|
229
|
+
*/
|
|
127
230
|
declare function isAssistantMessage(m: Message): m is Message & {
|
|
128
231
|
role: 'assistant';
|
|
129
232
|
};
|
|
233
|
+
/**
|
|
234
|
+
* Type guard narrowing a {@link Message} to `role: 'tool'` (a tool result turn).
|
|
235
|
+
*
|
|
236
|
+
* @param m The message to test.
|
|
237
|
+
* @returns `true` (and narrows `m`) when the message is a tool result.
|
|
238
|
+
* @example
|
|
239
|
+
* ```ts
|
|
240
|
+
* if (isToolMessage(m)) console.log(m.toolCallId);
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
130
243
|
declare function isToolMessage(m: Message): m is Message & {
|
|
131
244
|
role: 'tool';
|
|
132
245
|
};
|
|
246
|
+
/**
|
|
247
|
+
* Type guard narrowing a {@link Message} to `role: 'system'`.
|
|
248
|
+
*
|
|
249
|
+
* @param m The message to test.
|
|
250
|
+
* @returns `true` (and narrows `m`) when the message is a system message.
|
|
251
|
+
* @example
|
|
252
|
+
* ```ts
|
|
253
|
+
* const visible = agent.messages().filter((m) => !isSystemMessage(m));
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
133
256
|
declare function isSystemMessage(m: Message): m is Message & {
|
|
134
257
|
role: 'system';
|
|
135
258
|
};
|
|
@@ -166,6 +289,12 @@ interface Subagent {
|
|
|
166
289
|
name?: string;
|
|
167
290
|
status: Signal<SubagentStatus>;
|
|
168
291
|
messages: Signal<Message[]>;
|
|
292
|
+
/**
|
|
293
|
+
* The subagent's own tool calls (name/args/result), referenced by
|
|
294
|
+
* `Message.toolCallIds` in `messages`. Optional: adapters that don't surface
|
|
295
|
+
* subagent tool calls omit it; consumers default to `[]`.
|
|
296
|
+
*/
|
|
297
|
+
toolCalls?: Signal<ToolCall[]>;
|
|
169
298
|
state: Signal<Record<string, unknown>>;
|
|
170
299
|
}
|
|
171
300
|
|
|
@@ -246,6 +375,60 @@ interface ClientToolsCapability {
|
|
|
246
375
|
resolve(toolCallId: string, result: ClientToolResult): void;
|
|
247
376
|
}
|
|
248
377
|
|
|
378
|
+
/**
|
|
379
|
+
* The failure class of an {@link AgentError}, used to drive UI and retry logic:
|
|
380
|
+
*
|
|
381
|
+
* - `connection` — offline / DNS / connection refused / `fetch` failed. Retryable.
|
|
382
|
+
* - `auth` — `401` / `403`; credentials or API key are wrong. Not retryable.
|
|
383
|
+
* - `server` — a `5xx` (retryable) or a non-auth `4xx` like `400`/`404`/`429` (not retryable).
|
|
384
|
+
* - `interrupted` — the stream closed mid-response after a run had started. Retryable.
|
|
385
|
+
* - `aborted` — the user pressed stop; treated as a graceful idle, not surfaced as an error.
|
|
386
|
+
*/
|
|
387
|
+
type AgentErrorKind = 'connection' | 'auth' | 'server' | 'interrupted' | 'aborted';
|
|
388
|
+
/**
|
|
389
|
+
* Structured, classified failure surfaced on `Agent.error`. Extends `Error`, so
|
|
390
|
+
* existing `.message` / `instanceof Error` reads keep working — but adds a
|
|
391
|
+
* machine-readable {@link AgentErrorKind}, a `retryable` flag, an optional HTTP
|
|
392
|
+
* `status`, and the original `cause`.
|
|
393
|
+
*
|
|
394
|
+
* You rarely construct one yourself; adapters normalize raw failures via
|
|
395
|
+
* {@link toAgentError}. Read it off the agent to render legible, cause-specific UI:
|
|
396
|
+
*
|
|
397
|
+
* @example
|
|
398
|
+
* ```ts
|
|
399
|
+
* const err = agent.error(); // AgentError | undefined
|
|
400
|
+
* if (err) {
|
|
401
|
+
* console.warn(err.message); // legible, per-kind copy
|
|
402
|
+
* if (err.kind === 'auth') showApiKeyHelp();
|
|
403
|
+
* if (err.retryable) showRetryButton(); // → agent.retry()
|
|
404
|
+
* }
|
|
405
|
+
* ```
|
|
406
|
+
*/
|
|
407
|
+
declare class AgentError extends Error {
|
|
408
|
+
/** The classified failure type. See {@link AgentErrorKind}. */
|
|
409
|
+
readonly kind: AgentErrorKind;
|
|
410
|
+
/** Whether retrying the same request could plausibly succeed:
|
|
411
|
+
* `connection` | `server` (5xx) | `interrupted` → true; `auth` | `aborted` | non-auth `4xx` → false. */
|
|
412
|
+
readonly retryable: boolean;
|
|
413
|
+
/** The HTTP status code when the failure came from an HTTP response. */
|
|
414
|
+
readonly status?: number;
|
|
415
|
+
/** The original raw error this was classified from, preserved for debugging/telemetry. */
|
|
416
|
+
readonly cause: unknown;
|
|
417
|
+
constructor(init: {
|
|
418
|
+
kind: AgentErrorKind;
|
|
419
|
+
message: string;
|
|
420
|
+
retryable: boolean;
|
|
421
|
+
status?: number;
|
|
422
|
+
cause?: unknown;
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Default, human-facing copy per {@link AgentErrorKind}. Used as the message when
|
|
427
|
+
* a classified error has no better text. Override by mapping `error.kind` to your
|
|
428
|
+
* own strings in a custom error component.
|
|
429
|
+
*/
|
|
430
|
+
declare const AGENT_ERROR_MESSAGES: Record<AgentErrorKind, string>;
|
|
431
|
+
|
|
249
432
|
/**
|
|
250
433
|
* Runtime-neutral contract chat primitives consume.
|
|
251
434
|
*
|
|
@@ -259,15 +442,18 @@ interface ClientToolsCapability {
|
|
|
259
442
|
* Invariant: state lives on signals; `events$` carries only things that are
|
|
260
443
|
* not derivable from signals.
|
|
261
444
|
*/
|
|
262
|
-
interface Agent {
|
|
445
|
+
interface Agent<TState = Record<string, unknown>> {
|
|
263
446
|
messages: Signal<Message[]>;
|
|
264
447
|
status: Signal<AgentStatus>;
|
|
265
448
|
isLoading: Signal<boolean>;
|
|
266
|
-
error: Signal<
|
|
449
|
+
error: Signal<AgentError | undefined>;
|
|
267
450
|
toolCalls: Signal<ToolCall[]>;
|
|
268
|
-
state: Signal<
|
|
451
|
+
state: Signal<TState>;
|
|
269
452
|
submit: (input: AgentSubmitInput, opts?: AgentSubmitOptions) => Promise<void>;
|
|
270
453
|
stop: () => Promise<void>;
|
|
454
|
+
/** Re-run the last submitted input after a failure. No-op if a run is already
|
|
455
|
+
* in flight or there is nothing to retry. Clears `error` and sets loading. */
|
|
456
|
+
retry: () => Promise<void>;
|
|
271
457
|
/**
|
|
272
458
|
* Discards the assistant message at the given index AND all messages after
|
|
273
459
|
* it, then re-runs the agent against the trimmed conversation tail. The
|
|
@@ -285,6 +471,37 @@ interface Agent {
|
|
|
285
471
|
events$: Observable<AgentEvent>;
|
|
286
472
|
}
|
|
287
473
|
|
|
474
|
+
/**
|
|
475
|
+
* Whether `raw` represents an abort (a `DOMException`/`Error` named `AbortError`,
|
|
476
|
+
* or an abort-ish message). Shared by the runtime adapters and {@link toAgentError}
|
|
477
|
+
* so a user-requested stop settles to idle instead of surfacing as an error.
|
|
478
|
+
*
|
|
479
|
+
* @param raw Any thrown/rejected value.
|
|
480
|
+
* @returns `true` if it looks like an abort.
|
|
481
|
+
*/
|
|
482
|
+
declare function isAbortError(raw: unknown): boolean;
|
|
483
|
+
/**
|
|
484
|
+
* Classify any raw error into a structured {@link AgentError}.
|
|
485
|
+
*
|
|
486
|
+
* Resolution order (first match wins): an existing `AgentError` is returned
|
|
487
|
+
* unchanged (idempotent) → a user abort → a structured `status`/`cause.status`
|
|
488
|
+
* → network/connection markers → an HTTP-shaped status in the message → a
|
|
489
|
+
* `server` + retryable fallback. The original error is always preserved on
|
|
490
|
+
* `cause`. Runtime adapters call this before setting `Agent.error`; custom
|
|
491
|
+
* backends can call it too (or throw an `AgentError` directly).
|
|
492
|
+
*
|
|
493
|
+
* @param raw Any thrown/rejected value — an `Error`, a `{ status }` object, a string, etc.
|
|
494
|
+
* @returns The classified {@link AgentError} (kind, retryable, status?, cause).
|
|
495
|
+
* @example
|
|
496
|
+
* ```ts
|
|
497
|
+
* const e = toAgentError(new Error('HTTP 500: Internal Server Error'));
|
|
498
|
+
* e.kind; // 'server'
|
|
499
|
+
* e.retryable; // true
|
|
500
|
+
* e.status; // 500
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
503
|
+
declare function toAgentError(raw: unknown): AgentError;
|
|
504
|
+
|
|
288
505
|
/**
|
|
289
506
|
* Runtime-neutral snapshot of a point in an agent's execution history.
|
|
290
507
|
*
|
|
@@ -308,7 +525,7 @@ interface AgentCheckpoint {
|
|
|
308
525
|
* implement this. Pure request/response runtimes that don't have checkpoints
|
|
309
526
|
* should implement plain Agent.
|
|
310
527
|
*/
|
|
311
|
-
interface AgentWithHistory extends Agent {
|
|
528
|
+
interface AgentWithHistory<TState = Record<string, unknown>> extends Agent<TState> {
|
|
312
529
|
history: Signal<AgentCheckpoint[]>;
|
|
313
530
|
/**
|
|
314
531
|
* Optional reactive map of `messageId → checkpointId`, computed by
|
|
@@ -320,6 +537,27 @@ interface AgentWithHistory extends Agent {
|
|
|
320
537
|
messageCheckpoints?: Signal<ReadonlyMap<string, string>>;
|
|
321
538
|
}
|
|
322
539
|
|
|
540
|
+
/** A typed handle that threads a state shape through Angular DI from
|
|
541
|
+
* `provideAgent(ref, …)` to `injectAgent(ref)` without per-call-site
|
|
542
|
+
* restatement of the generic. */
|
|
543
|
+
interface AgentRef<TState> {
|
|
544
|
+
readonly token: InjectionToken<Agent<TState>>;
|
|
545
|
+
}
|
|
546
|
+
/**
|
|
547
|
+
* Create a typed agent handle.
|
|
548
|
+
*
|
|
549
|
+
* @param debugName Optional name shown in Angular DI error messages.
|
|
550
|
+
* @returns An {@link AgentRef} carrying a state-typed `InjectionToken`.
|
|
551
|
+
* @example
|
|
552
|
+
* ```ts
|
|
553
|
+
* interface TripState { day: number; places: string[]; }
|
|
554
|
+
* export const TRIP = createAgentRef<TripState>('trip');
|
|
555
|
+
* // app.config.ts: provideAgent(TRIP, { assistantId: 'trip' })
|
|
556
|
+
* // component: const agent = injectAgent(TRIP); // LangGraphAgent<TripState>
|
|
557
|
+
* ```
|
|
558
|
+
*/
|
|
559
|
+
declare function createAgentRef<TState>(debugName?: string): AgentRef<TState>;
|
|
560
|
+
|
|
323
561
|
type AgentRuntimeTelemetryEvent = 'ngaf:runtime_instance_created' | 'ngaf:runtime_request_created' | 'ngaf:stream_started' | 'ngaf:stream_ended' | 'ngaf:stream_errored';
|
|
324
562
|
interface AgentRuntimeTelemetryProperties {
|
|
325
563
|
transport: 'langgraph' | 'ag-ui' | 'custom' | string;
|
|
@@ -349,7 +587,7 @@ declare class MessageTemplateDirective {
|
|
|
349
587
|
*/
|
|
350
588
|
declare function getMessageType(message: Message): MessageTemplateType;
|
|
351
589
|
declare class ChatMessageListComponent {
|
|
352
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
590
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
353
591
|
readonly messageTemplates: _angular_core.Signal<readonly MessageTemplateDirective[]>;
|
|
354
592
|
readonly messages: _angular_core.Signal<Message[]>;
|
|
355
593
|
readonly getMessageType: typeof getMessageType;
|
|
@@ -484,7 +722,7 @@ declare class ChatSuggestionsComponent {
|
|
|
484
722
|
*/
|
|
485
723
|
declare function submitMessage(agent: Agent, text: string): string | null;
|
|
486
724
|
declare class ChatInputComponent {
|
|
487
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
725
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
488
726
|
readonly submitOnEnter: _angular_core.InputSignal<boolean>;
|
|
489
727
|
readonly placeholder: _angular_core.InputSignal<string>;
|
|
490
728
|
/** When true (default), shows a stop button while the agent is streaming. */
|
|
@@ -522,9 +760,21 @@ declare class ChatInputComponent {
|
|
|
522
760
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ChatInputComponent, "chat-input", never, { "agent": { "alias": "agent"; "required": true; "isSignal": true; }; "submitOnEnter": { "alias": "submitOnEnter"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "showStopButton": { "alias": "showStopButton"; "required": false; "isSignal": true; }; }, { "submitted": "submitted"; "stopped": "stopped"; }, never, ["[chatInputBanner]", "[chatInputAttachments]", "[chatInputLeading]", "[chatInputModelSelect]", "[chatInputTrailing]", "[chatInputFooter]"], true, never>;
|
|
523
761
|
}
|
|
524
762
|
|
|
763
|
+
/**
|
|
764
|
+
* Whether the agent should show a "typing" indicator — it is loading and has
|
|
765
|
+
* not yet started streaming the assistant's reply.
|
|
766
|
+
*
|
|
767
|
+
* @param agent The agent to inspect.
|
|
768
|
+
* @returns `true` while the agent is awaiting a response but no assistant text
|
|
769
|
+
* has streamed yet; `false` once tokens arrive or the agent is idle.
|
|
770
|
+
* @example
|
|
771
|
+
* ```ts
|
|
772
|
+
* \@if (isTyping(agent)) { <chat-typing-indicator [agent]="agent" /> }
|
|
773
|
+
* ```
|
|
774
|
+
*/
|
|
525
775
|
declare function isTyping(agent: Agent): boolean;
|
|
526
776
|
declare class ChatTypingIndicatorComponent {
|
|
527
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
777
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
528
778
|
readonly visible: _angular_core.Signal<boolean>;
|
|
529
779
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ChatTypingIndicatorComponent, never>;
|
|
530
780
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ChatTypingIndicatorComponent, "chat-typing-indicator", never, { "agent": { "alias": "agent"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
@@ -620,15 +870,26 @@ declare class ChatScrollBubbleComponent {
|
|
|
620
870
|
|
|
621
871
|
declare function extractErrorMessage(error: unknown): string | null;
|
|
622
872
|
declare class ChatErrorComponent {
|
|
623
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
624
|
-
readonly errorMessage: _angular_core.Signal<string | null>;
|
|
873
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
625
874
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ChatErrorComponent, never>;
|
|
626
875
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ChatErrorComponent, "chat-error", never, { "agent": { "alias": "agent"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
627
876
|
}
|
|
628
877
|
|
|
878
|
+
/**
|
|
879
|
+
* Read the agent's current human-in-the-loop interrupt, if any.
|
|
880
|
+
*
|
|
881
|
+
* @param agent The agent to inspect.
|
|
882
|
+
* @returns The pending {@link AgentInterrupt}, or `undefined` when the agent is
|
|
883
|
+
* not currently waiting on an interrupt.
|
|
884
|
+
* @example
|
|
885
|
+
* ```ts
|
|
886
|
+
* const interrupt = getInterrupt(agent);
|
|
887
|
+
* if (interrupt) agent.resume('approved');
|
|
888
|
+
* ```
|
|
889
|
+
*/
|
|
629
890
|
declare function getInterrupt(agent: Agent): AgentInterrupt | undefined;
|
|
630
891
|
declare class ChatInterruptComponent {
|
|
631
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
892
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
632
893
|
readonly templateRef: _angular_core.Signal<TemplateRef<any> | undefined>;
|
|
633
894
|
readonly interrupt: _angular_core.Signal<AgentInterrupt | undefined>;
|
|
634
895
|
defaultText(i: AgentInterrupt): string;
|
|
@@ -695,9 +956,11 @@ interface Group {
|
|
|
695
956
|
name: string;
|
|
696
957
|
calls: ToolCall[];
|
|
697
958
|
templateRef?: ChatToolCallTemplateDirective;
|
|
959
|
+
/** Present when this group anchors a subagent spawned by its (single) task call. */
|
|
960
|
+
subagent?: Subagent;
|
|
698
961
|
}
|
|
699
962
|
declare class ChatToolCallsComponent {
|
|
700
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
963
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
701
964
|
readonly message: _angular_core.InputSignal<Message | undefined>;
|
|
702
965
|
readonly grouping: _angular_core.InputSignal<"auto" | "none">;
|
|
703
966
|
readonly groupSummary: _angular_core.InputSignal<((name: string, count: number) => string) | undefined>;
|
|
@@ -736,7 +999,7 @@ declare class ChatToolCallsComponent {
|
|
|
736
999
|
* (and a `status` a component chooses not to declare) are harmless.
|
|
737
1000
|
*/
|
|
738
1001
|
declare class ChatToolViewsComponent {
|
|
739
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
1002
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
740
1003
|
readonly events: _angular_core.OutputEmitterRef<RenderEvent>;
|
|
741
1004
|
readonly message: _angular_core.InputSignal<Message | undefined>;
|
|
742
1005
|
readonly views: _angular_core.InputSignal<Readonly<Record<string, _angular_core.Type<unknown> | _threadplane_render.RenderViewEntry>> | undefined>;
|
|
@@ -753,7 +1016,7 @@ declare class ChatToolViewsComponent {
|
|
|
753
1016
|
}
|
|
754
1017
|
|
|
755
1018
|
declare class ChatSubagentsComponent {
|
|
756
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
1019
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
757
1020
|
readonly templateRef: _angular_core.Signal<TemplateRef<any> | undefined>;
|
|
758
1021
|
readonly activeSubagents: _angular_core.Signal<Subagent[]>;
|
|
759
1022
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ChatSubagentsComponent, never>;
|
|
@@ -959,7 +1222,7 @@ declare class ChatGenuiSkeletonComponent {
|
|
|
959
1222
|
}
|
|
960
1223
|
|
|
961
1224
|
declare class ChatTimelineComponent {
|
|
962
|
-
readonly agent: _angular_core.InputSignal<AgentWithHistory
|
|
1225
|
+
readonly agent: _angular_core.InputSignal<AgentWithHistory<Record<string, unknown>>>;
|
|
963
1226
|
readonly checkpointSelected: _angular_core.OutputEmitterRef<AgentCheckpoint>;
|
|
964
1227
|
readonly templateRef: _angular_core.Signal<TemplateRef<any> | undefined>;
|
|
965
1228
|
readonly history: _angular_core.Signal<AgentCheckpoint[]>;
|
|
@@ -1013,14 +1276,17 @@ declare class ChatWelcomeComponent {
|
|
|
1013
1276
|
declare class ChatWelcomeSuggestionComponent {
|
|
1014
1277
|
readonly label: _angular_core.InputSignal<string>;
|
|
1015
1278
|
readonly value: _angular_core.InputSignal<string>;
|
|
1279
|
+
/** Optional short description, surfaced as a hover/focus tooltip on the chip. */
|
|
1280
|
+
readonly description: _angular_core.InputSignal<string | undefined>;
|
|
1016
1281
|
readonly selected: _angular_core.OutputEmitterRef<string>;
|
|
1017
1282
|
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>;
|
|
1283
|
+
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
1284
|
}
|
|
1020
1285
|
|
|
1021
1286
|
interface ChatSelectOption {
|
|
1022
1287
|
value: string;
|
|
1023
1288
|
label: string;
|
|
1289
|
+
description?: string;
|
|
1024
1290
|
disabled?: boolean;
|
|
1025
1291
|
}
|
|
1026
1292
|
/**
|
|
@@ -1101,6 +1367,35 @@ declare class ChatCitationsCardComponent {
|
|
|
1101
1367
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ChatCitationsCardComponent, "chat-citations-card", never, { "citation": { "alias": "citation"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1102
1368
|
}
|
|
1103
1369
|
|
|
1370
|
+
interface ThreadRoutingConfig {
|
|
1371
|
+
/** The app-owned source-of-truth signal for the active thread id. */
|
|
1372
|
+
threadId: WritableSignal<string | null>;
|
|
1373
|
+
/** Router commands for a thread id (or the bare/welcome path when null).
|
|
1374
|
+
* Default: `(id) => (id ? ['/', id] : ['/'])`. */
|
|
1375
|
+
toCommands?: (id: string | null) => unknown[];
|
|
1376
|
+
/** Extract the thread id from a URL (null = bare). Default: last non-empty path segment. */
|
|
1377
|
+
threadIdFromUrl?: (url: string) => string | null;
|
|
1378
|
+
/** Optional async validity check; on `false` the helper redirects to the bare path
|
|
1379
|
+
* (`replaceUrl: true`). LangGraph apps pass `id => threads.getThread(id).then(Boolean)`. */
|
|
1380
|
+
validate?: (id: string) => Promise<boolean>;
|
|
1381
|
+
/** Extras merged into every navigate (default `{ queryParamsHandling: 'preserve' }`). */
|
|
1382
|
+
navigationExtras?: NavigationExtras;
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Bind an app-owned `activeThreadId` signal to the URL — restore on load, stamp on change,
|
|
1386
|
+
* validate-or-redirect, with a bare URL meaning "no thread" (welcome). URL is the source of
|
|
1387
|
+
* truth; nothing is written to localStorage. Must be called in an injection context.
|
|
1388
|
+
*
|
|
1389
|
+
* @example
|
|
1390
|
+
* ```ts
|
|
1391
|
+
* export const ACTIVE_THREAD = signal<string | null>(null);
|
|
1392
|
+
* // providers: provideAgent({ threadId: ACTIVE_THREAD, onThreadId: id => ACTIVE_THREAD.set(id) })
|
|
1393
|
+
* const threads = inject(LangGraphThreadsAdapter);
|
|
1394
|
+
* injectThreadRouting({ threadId: ACTIVE_THREAD, validate: id => threads.getThread(id).then(Boolean) });
|
|
1395
|
+
* ```
|
|
1396
|
+
*/
|
|
1397
|
+
declare function injectThreadRouting(config: ThreadRoutingConfig): void;
|
|
1398
|
+
|
|
1104
1399
|
interface ChatLifecycle {
|
|
1105
1400
|
/** True after `<chat>` initializes with a non-null agent binding. */
|
|
1106
1401
|
readonly componentReady: Signal<boolean>;
|
|
@@ -1124,6 +1419,21 @@ interface ParseTreeStore {
|
|
|
1124
1419
|
readonly spec: Signal<Spec | null>;
|
|
1125
1420
|
readonly elementStates: Signal<Map<string, ElementAccumulationState>>;
|
|
1126
1421
|
}
|
|
1422
|
+
/**
|
|
1423
|
+
* Create a {@link ParseTreeStore} — feeds streamed JSON chunks through a
|
|
1424
|
+
* partial-JSON parser and exposes the progressively-materialized spec and
|
|
1425
|
+
* per-element accumulation state as signals, so a generative-UI surface can
|
|
1426
|
+
* render while the spec is still arriving.
|
|
1427
|
+
*
|
|
1428
|
+
* @param parser The partial-JSON parser used to incrementally materialize chunks.
|
|
1429
|
+
* @returns A {@link ParseTreeStore}; call `push(chunk)` as bytes stream in.
|
|
1430
|
+
* @example
|
|
1431
|
+
* ```ts
|
|
1432
|
+
* const store = createParseTreeStore(parser);
|
|
1433
|
+
* store.push('{"type":"Car');
|
|
1434
|
+
* store.spec(); // best-effort Spec | null
|
|
1435
|
+
* ```
|
|
1436
|
+
*/
|
|
1127
1437
|
declare function createParseTreeStore(parser: PartialJsonParser): ParseTreeStore;
|
|
1128
1438
|
|
|
1129
1439
|
/** Chat-internal projection of an A2UI component, materialized by the
|
|
@@ -1178,6 +1488,19 @@ interface A2uiSurfaceStore {
|
|
|
1178
1488
|
readonly surfaceStates: Signal<Map<string, A2uiSurfaceState>>;
|
|
1179
1489
|
surfaceState(surfaceId: string): Signal<A2uiSurfaceState | undefined>;
|
|
1180
1490
|
}
|
|
1491
|
+
/**
|
|
1492
|
+
* Create an {@link A2uiSurfaceStore} — the per-conversation store that buffers
|
|
1493
|
+
* streamed A2UI surface updates, tracks each surface's data model + lifecycle
|
|
1494
|
+
* state, and exposes them as signals for rendering. One store backs a chat
|
|
1495
|
+
* thread's A2UI surfaces.
|
|
1496
|
+
*
|
|
1497
|
+
* @returns A fresh, empty {@link A2uiSurfaceStore}.
|
|
1498
|
+
* @example
|
|
1499
|
+
* ```ts
|
|
1500
|
+
* const store = createA2uiSurfaceStore();
|
|
1501
|
+
* const surfaces = store.surfaces; // Signal<Map<string, A2uiSurface>>
|
|
1502
|
+
* ```
|
|
1503
|
+
*/
|
|
1181
1504
|
declare function createA2uiSurfaceStore(): A2uiSurfaceStore;
|
|
1182
1505
|
|
|
1183
1506
|
type ContentType = 'pending' | 'markdown' | 'json-render' | 'a2ui' | 'mixed';
|
|
@@ -1193,6 +1516,19 @@ interface ContentClassifier {
|
|
|
1193
1516
|
readonly errors: Signal<string[]>;
|
|
1194
1517
|
dispose(): void;
|
|
1195
1518
|
}
|
|
1519
|
+
/**
|
|
1520
|
+
* Create a {@link ContentClassifier} — the streaming accumulator that inspects
|
|
1521
|
+
* an assistant message's content as it arrives and classifies it (markdown vs a
|
|
1522
|
+
* generative-UI/A2UI spec), exposing the parsed result and per-element state as
|
|
1523
|
+
* signals so the renderer can switch modes mid-stream.
|
|
1524
|
+
*
|
|
1525
|
+
* @returns A fresh {@link ContentClassifier}; call `dispose()` when done.
|
|
1526
|
+
* @example
|
|
1527
|
+
* ```ts
|
|
1528
|
+
* const cc = createContentClassifier();
|
|
1529
|
+
* effect(() => console.log(cc.type())); // 'pending' | 'markdown' | 'spec'
|
|
1530
|
+
* ```
|
|
1531
|
+
*/
|
|
1196
1532
|
declare function createContentClassifier(): ContentClassifier;
|
|
1197
1533
|
|
|
1198
1534
|
/**
|
|
@@ -1214,7 +1550,7 @@ interface ChatRenderEvent {
|
|
|
1214
1550
|
}
|
|
1215
1551
|
|
|
1216
1552
|
declare class ChatComponent {
|
|
1217
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
1553
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
1218
1554
|
readonly views: _angular_core.InputSignal<Readonly<Record<string, _angular_core.Type<unknown> | _threadplane_render.RenderViewEntry>> | undefined>;
|
|
1219
1555
|
/**
|
|
1220
1556
|
* Client-declared tools (`view`/`ask`/`function`) the model may call. When
|
|
@@ -1421,7 +1757,7 @@ declare class ChatComponent {
|
|
|
1421
1757
|
}
|
|
1422
1758
|
|
|
1423
1759
|
declare class ChatPopupComponent {
|
|
1424
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
1760
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
1425
1761
|
/** A2UI component catalog forwarded to the inner <chat>. Without it,
|
|
1426
1762
|
* messages classified as A2UI parse correctly but never mount a
|
|
1427
1763
|
* surface. Pass `a2uiBasicCatalog()` from `@threadplane/chat`. */
|
|
@@ -1461,7 +1797,7 @@ declare class ChatPopupComponent {
|
|
|
1461
1797
|
}
|
|
1462
1798
|
|
|
1463
1799
|
declare class ChatSidebarComponent {
|
|
1464
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
1800
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
1465
1801
|
/** A2UI component catalog forwarded to the inner <chat>. Without it,
|
|
1466
1802
|
* messages classified as A2UI parse correctly but never mount a
|
|
1467
1803
|
* surface. Pass `a2uiBasicCatalog()` from `@threadplane/chat`. */
|
|
@@ -1495,7 +1831,7 @@ declare class ChatSidebarComponent {
|
|
|
1495
1831
|
}
|
|
1496
1832
|
|
|
1497
1833
|
declare class ChatTimelineSliderComponent {
|
|
1498
|
-
readonly agent: _angular_core.InputSignal<AgentWithHistory
|
|
1834
|
+
readonly agent: _angular_core.InputSignal<AgentWithHistory<Record<string, unknown>>>;
|
|
1499
1835
|
readonly selectedIndex: _angular_core.WritableSignal<number>;
|
|
1500
1836
|
readonly history: _angular_core.Signal<AgentCheckpoint[]>;
|
|
1501
1837
|
readonly replayRequested: _angular_core.OutputEmitterRef<string>;
|
|
@@ -1517,7 +1853,7 @@ declare class ChatSidenavComponent {
|
|
|
1517
1853
|
readonly projects: _angular_core.InputSignal<Project[] | null>;
|
|
1518
1854
|
readonly selectedProjectId: _angular_core.InputSignal<string | null>;
|
|
1519
1855
|
readonly projectActions: _angular_core.InputSignal<ProjectActionAdapter | null>;
|
|
1520
|
-
readonly agent: _angular_core.InputSignal<Agent | AgentWithHistory | null>;
|
|
1856
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>> | AgentWithHistory<Record<string, unknown>> | null>;
|
|
1521
1857
|
readonly debug: _angular_core.InputSignal<boolean>;
|
|
1522
1858
|
readonly newChat: _angular_core.OutputEmitterRef<void>;
|
|
1523
1859
|
readonly threadSelected: _angular_core.OutputEmitterRef<string>;
|
|
@@ -1568,7 +1904,7 @@ declare class ChatSidenavScrimComponent {
|
|
|
1568
1904
|
|
|
1569
1905
|
type InterruptAction = 'accept' | 'edit' | 'respond' | 'ignore';
|
|
1570
1906
|
declare class ChatInterruptPanelComponent {
|
|
1571
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
1907
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
1572
1908
|
readonly action: _angular_core.OutputEmitterRef<InterruptAction>;
|
|
1573
1909
|
readonly interrupt: _angular_core.Signal<AgentInterrupt | undefined>;
|
|
1574
1910
|
readonly interruptReason: _angular_core.Signal<string>;
|
|
@@ -1578,7 +1914,7 @@ declare class ChatInterruptPanelComponent {
|
|
|
1578
1914
|
|
|
1579
1915
|
type ChatApprovalAction = 'approve' | 'edit' | 'cancel';
|
|
1580
1916
|
declare class ChatApprovalCardComponent {
|
|
1581
|
-
readonly agent: _angular_core.InputSignal<Agent
|
|
1917
|
+
readonly agent: _angular_core.InputSignal<Agent<Record<string, unknown>>>;
|
|
1582
1918
|
readonly matchKind: _angular_core.InputSignal<string | undefined>;
|
|
1583
1919
|
readonly title: _angular_core.InputSignal<string>;
|
|
1584
1920
|
readonly showEdit: _angular_core.InputSignal<boolean>;
|
|
@@ -1608,7 +1944,9 @@ declare function statusColor(status: SubagentStatus): string;
|
|
|
1608
1944
|
declare class ChatSubagentCardComponent {
|
|
1609
1945
|
readonly subagent: _angular_core.InputSignal<Subagent>;
|
|
1610
1946
|
readonly state: _angular_core.Signal<TraceState>;
|
|
1611
|
-
|
|
1947
|
+
protected textOf(m: Message): string;
|
|
1948
|
+
protected toolCallsFor(m: Message): ToolCall[];
|
|
1949
|
+
protected toToolCallInfo(tc: ToolCall): ToolCallInfo;
|
|
1612
1950
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ChatSubagentCardComponent, never>;
|
|
1613
1951
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ChatSubagentCardComponent, "chat-subagent-card", never, { "subagent": { "alias": "subagent"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
1614
1952
|
}
|
|
@@ -1844,8 +2182,6 @@ declare class MarkdownTableCellComponent {
|
|
|
1844
2182
|
*/
|
|
1845
2183
|
declare const IS_HEADER_ROW: InjectionToken<Signal<boolean>>;
|
|
1846
2184
|
|
|
1847
|
-
declare const CHAT_MARKDOWN_STYLES = "\n chat-streaming-md { display: block; color: var(--ngaf-chat-text); line-height: var(--ngaf-chat-line-height); }\n\n /* Headings */\n chat-streaming-md h1, chat-streaming-md h2, chat-streaming-md h3, chat-streaming-md h4, chat-streaming-md h5, chat-streaming-md h6 {\n font-weight: 600;\n line-height: 1.25;\n margin: 1.25rem 0 0.75rem;\n }\n chat-streaming-md h1:first-child, chat-streaming-md h2:first-child, chat-streaming-md h3:first-child,\n chat-streaming-md h4:first-child, chat-streaming-md h5:first-child, chat-streaming-md h6:first-child { margin-top: 0; }\n chat-streaming-md h1 { font-size: 1.5em; font-weight: 700; }\n chat-streaming-md h2 { font-size: 1.25em; }\n chat-streaming-md h3 { font-size: 1.1em; }\n chat-streaming-md h4 { font-size: 1em; }\n chat-streaming-md h5, chat-streaming-md h6 { font-size: 0.95em; color: var(--ngaf-chat-text-muted); }\n\n /* Paragraphs and inline emphasis */\n chat-streaming-md p { margin: 0 0 0.75rem; line-height: 1.6; font-size: var(--ngaf-chat-font-size); }\n chat-streaming-md p:last-child { margin-bottom: 0; }\n chat-streaming-md strong, chat-streaming-md b { font-weight: 700; }\n chat-streaming-md em, chat-streaming-md i { font-style: italic; }\n chat-streaming-md del, chat-streaming-md s { text-decoration: line-through; color: var(--ngaf-chat-text-muted); }\n chat-streaming-md mark { background: var(--ngaf-chat-surface-alt); padding: 0 2px; border-radius: 2px; }\n chat-streaming-md sub { font-size: 0.75em; vertical-align: sub; }\n chat-streaming-md sup { font-size: 0.75em; vertical-align: super; }\n\n /* Links */\n chat-streaming-md a { color: var(--ngaf-chat-primary); text-decoration: underline; text-underline-offset: 2px; }\n chat-streaming-md a:hover { text-decoration-thickness: 2px; }\n\n /* Lists (CommonMark + GFM task lists) */\n chat-streaming-md ul, chat-streaming-md ol { margin: 0 0 0.75rem; padding-left: 1.5rem; }\n chat-streaming-md ul { list-style: disc outside; }\n chat-streaming-md ol { list-style: decimal outside; }\n chat-streaming-md ul ul { list-style: circle outside; }\n chat-streaming-md ul ul ul { list-style: square outside; }\n chat-streaming-md li { margin: 0.2rem 0; }\n chat-streaming-md li::marker { color: var(--ngaf-chat-text-muted); }\n chat-streaming-md li > p { margin: 0 0 0.25rem; }\n chat-streaming-md li > ul, chat-streaming-md li > ol { margin: 0.25rem 0 0; }\n /* GFM task lists: marked emits <li><input type=\"checkbox\" disabled> ... */\n chat-streaming-md li:has(> input[type=\"checkbox\"]) { list-style: none; margin-left: -1.25rem; }\n chat-streaming-md li > input[type=\"checkbox\"] { margin-right: 0.5rem; vertical-align: middle; }\n\n /* Code (inline + fenced) */\n chat-streaming-md code {\n background: var(--ngaf-chat-surface-alt);\n color: var(--ngaf-chat-text);\n padding: 1px 5px;\n border-radius: 4px;\n font-family: var(--ngaf-chat-font-mono);\n font-size: 0.9em;\n }\n chat-streaming-md pre {\n background: var(--ngaf-chat-surface-alt);\n color: var(--ngaf-chat-text);\n padding: 12px 14px;\n border-radius: var(--ngaf-chat-radius-card);\n overflow-x: auto;\n font-family: var(--ngaf-chat-font-mono);\n font-size: var(--ngaf-chat-font-size-sm);\n line-height: 1.5;\n margin: 0 0 0.75rem;\n }\n chat-streaming-md pre code { background: transparent; padding: 0; border-radius: 0; font-size: inherit; }\n\n /* Blockquote */\n chat-streaming-md blockquote {\n border-left: 3px solid var(--ngaf-chat-separator);\n padding: 0.25rem 0 0.25rem 12px;\n margin: 0 0 0.75rem;\n color: var(--ngaf-chat-text-muted);\n }\n chat-streaming-md blockquote > :last-child { margin-bottom: 0; }\n\n /* Horizontal rule */\n chat-streaming-md hr {\n border: none;\n border-top: 1px solid var(--ngaf-chat-separator);\n margin: 1rem 0;\n }\n\n /* Tables (GFM) */\n chat-streaming-md table {\n border-collapse: collapse;\n margin: 0 0 0.75rem;\n width: 100%;\n font-size: 0.95em;\n }\n chat-streaming-md thead { background: var(--ngaf-chat-surface-alt); }\n chat-streaming-md th, chat-streaming-md td {\n border: 1px solid var(--ngaf-chat-separator);\n padding: 6px 10px;\n text-align: left;\n vertical-align: top;\n }\n chat-streaming-md th { font-weight: 600; }\n /* Component-rendered table: chat-md-table becomes a horizontally-scrollable\n wrapper for the inner <table>; row/cell elements stay layout-transparent\n so the browser's table layout takes over. Without this overflow wrapper,\n wide tables push their parent container past the viewport horizontally. */\n chat-streaming-md chat-md-table {\n display: block;\n overflow-x: auto;\n max-width: 100%;\n margin: 0 0 0.75rem;\n }\n chat-streaming-md chat-md-table-row { display: contents; }\n chat-streaming-md chat-md-table-cell { display: contents; }\n chat-streaming-md chat-md-table > table { margin: 0; }\n /* Task-list items: checkbox + first paragraph render inline; subsequent\n blocks (sub-lists, multi-paragraph items) flow normally below. */\n chat-streaming-md li.chat-md-list-item--task {\n list-style: none;\n margin-left: -1.25rem;\n display: flex;\n flex-wrap: wrap;\n align-items: baseline;\n gap: 0.5rem;\n }\n chat-streaming-md li.chat-md-list-item--task > input[type=\"checkbox\"] {\n margin: 0;\n flex: 0 0 auto;\n transform: translateY(2px);\n }\n /* The chat-md-children wrapper around list-item content takes remaining width */\n chat-streaming-md li.chat-md-list-item--task > chat-md-children {\n flex: 1 1 auto;\n min-width: 0;\n }\n /* Tight task items: only the FIRST paragraph aligns inline with the\n checkbox (margin collapsed). Subsequent paragraphs/blocks keep their\n normal vertical spacing so multi-block items render readably. */\n chat-streaming-md li.chat-md-list-item--task > chat-md-children > chat-md-paragraph:first-child > p {\n margin: 0;\n }\n\n /* Media */\n chat-streaming-md img { max-width: 100%; height: auto; border-radius: 6px; }\n /* Broken-image fallback: muted pill showing alt text + icon. Triggered\n when <img> fires (error). Caught by live browser smoke \u2014 prior impl\n showed only the browser's broken-image icon with no readable alt. */\n chat-streaming-md .chat-md-image--broken {\n display: inline-flex;\n align-items: center;\n gap: 0.4rem;\n padding: 0.25rem 0.5rem;\n background: var(--ngaf-chat-surface-alt);\n border: 1px dashed var(--ngaf-chat-separator);\n border-radius: 6px;\n font-size: 0.9em;\n color: var(--ngaf-chat-text-muted, currentColor);\n opacity: 0.85;\n }\n chat-streaming-md .chat-md-image__icon { font-size: 1em; line-height: 1; }\n chat-streaming-md .chat-md-image__alt { font-style: italic; }\n";
|
|
1848
|
-
|
|
1849
2185
|
/**
|
|
1850
2186
|
* Renders markdown content to sanitized HTML.
|
|
1851
2187
|
* Falls back to plain text with newline->br conversion if `marked` is not installed.
|
|
@@ -1865,21 +2201,6 @@ declare function renderMarkdown(content: string, sanitizer: DomSanitizer): SafeH
|
|
|
1865
2201
|
*/
|
|
1866
2202
|
declare function formatDuration(ms: number): string;
|
|
1867
2203
|
|
|
1868
|
-
/** Chevron down (▼ replacement). 12x12, stroke-based. */
|
|
1869
|
-
declare const ICON_CHEVRON_DOWN = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 4.5L6 7.5L9 4.5\"/></svg>";
|
|
1870
|
-
/** Chevron up (▲ replacement). 12x12, stroke-based. */
|
|
1871
|
-
declare const ICON_CHEVRON_UP = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 7.5L6 4.5L9 7.5\"/></svg>";
|
|
1872
|
-
/** Gear icon (⚙ replacement). 14x14. */
|
|
1873
|
-
declare const ICON_TOOL = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><circle cx=\"12\" cy=\"12\" r=\"3\"/><path d=\"M12 1v2M12 21v2M4.22 4.22l1.42 1.42M18.36 18.36l1.42 1.42M1 12h2M21 12h2M4.22 19.78l1.42-1.42M18.36 5.64l1.42-1.42\"/></svg>";
|
|
1874
|
-
/** Warning triangle (⚠ replacement). 18x18. */
|
|
1875
|
-
declare const ICON_WARNING = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z\"/><line x1=\"12\" y1=\"9\" x2=\"12\" y2=\"13\"/><line x1=\"12\" y1=\"17\" x2=\"12.01\" y2=\"17\"/></svg>";
|
|
1876
|
-
/** Robot/agent icon (replacement). 14x14. */
|
|
1877
|
-
declare const ICON_AGENT = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"11\" width=\"18\" height=\"10\" rx=\"2\"/><circle cx=\"12\" cy=\"5\" r=\"2\"/><path d=\"M12 7v4\"/><line x1=\"8\" y1=\"16\" x2=\"8\" y2=\"16\"/><line x1=\"16\" y1=\"16\" x2=\"16\" y2=\"16\"/></svg>";
|
|
1878
|
-
/** Check mark replacement. 12x12. */
|
|
1879
|
-
declare const ICON_CHECK = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"12\" height=\"12\" viewBox=\"0 0 12 12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M2.5 6L5 8.5L9.5 3.5\"/></svg>";
|
|
1880
|
-
/** Send arrow (for chat input). 16x16. */
|
|
1881
|
-
declare const ICON_SEND = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M8 12V4M8 4L4 8M8 4L12 8\"/></svg>";
|
|
1882
|
-
|
|
1883
2204
|
/** Catalog entry for the A2UI surface renderer.
|
|
1884
2205
|
*
|
|
1885
2206
|
* `component` is mounted once all of the component's bindings (data
|
|
@@ -1997,14 +2318,24 @@ declare class A2uiSurfaceComponent {
|
|
|
1997
2318
|
static ɵcmp: _angular_core.ɵɵComponentDeclaration<A2uiSurfaceComponent, "a2ui-surface", never, { "surface": { "alias": "surface"; "required": false; "isSignal": true; }; "state": { "alias": "state"; "required": false; "isSignal": true; }; "catalog": { "alias": "catalog"; "required": true; "isSignal": true; }; "handlers": { "alias": "handlers"; "required": false; "isSignal": true; }; "surfaceFallback": { "alias": "surfaceFallback"; "required": false; "isSignal": true; }; }, { "events": "events"; "action": "action"; }, never, never, true, never>;
|
|
1998
2319
|
}
|
|
1999
2320
|
|
|
2000
|
-
declare function surfaceToSpec(surface: A2uiSurface): Spec | null;
|
|
2001
|
-
|
|
2002
2321
|
/** Builds an A2uiActionMessage from handler params and the current surface.
|
|
2003
2322
|
* The action.context is serialized as v1 DynamicValue-wrapped entries.
|
|
2004
2323
|
* Sets action.label when the source component is a Button with a Text
|
|
2005
2324
|
* child whose literalString is non-empty. */
|
|
2006
2325
|
declare function buildA2uiActionMessage(params: Record<string, unknown>, surface: A2uiSurface): A2uiActionMessage;
|
|
2007
2326
|
|
|
2327
|
+
/**
|
|
2328
|
+
* Build the built-in A2UI component catalog — a {@link ViewRegistry} mapping
|
|
2329
|
+
* the standard A2UI element types (Card, Button, TextField, Image, AudioPlayer,
|
|
2330
|
+
* Video, …) to their Angular renderers. Spread it into `provideViews` (with any
|
|
2331
|
+
* of your own views) so an agent's A2UI surface specs render.
|
|
2332
|
+
*
|
|
2333
|
+
* @returns A {@link ViewRegistry} of the standard A2UI components.
|
|
2334
|
+
* @example
|
|
2335
|
+
* ```ts
|
|
2336
|
+
* providers: [provideViews({ ...a2uiBasicCatalog(), MyWidget: MyWidgetComponent })]
|
|
2337
|
+
* ```
|
|
2338
|
+
*/
|
|
2008
2339
|
declare function a2uiBasicCatalog(): ViewRegistry;
|
|
2009
2340
|
|
|
2010
2341
|
/** Writes a typed value to the render state store if the prop has a binding path. */
|
|
@@ -2348,37 +2679,164 @@ declare class A2uiVideoComponent {
|
|
|
2348
2679
|
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
2680
|
}
|
|
2350
2681
|
|
|
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>>;
|
|
2682
|
+
/**
|
|
2683
|
+
* @internal
|
|
2684
|
+
* Identity mapped type that flattens an object type so editor quick-info shows
|
|
2685
|
+
* the expanded shape instead of a raw conditional/mapped-type expression.
|
|
2686
|
+
*/
|
|
2687
|
+
type Prettify<T> = {
|
|
2688
|
+
[K in keyof T]: T[K];
|
|
2689
|
+
} & {};
|
|
2373
2690
|
|
|
2374
|
-
/**
|
|
2375
|
-
|
|
2376
|
-
/**
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2691
|
+
/** Value type carried by an Angular signal input. */
|
|
2692
|
+
type InputValue<P> = P extends InputSignal<infer T> ? T : P extends InputSignalWithTransform<infer T, infer _U> ? T : never;
|
|
2693
|
+
/** A component instance's declared signal inputs, as a plain prop bag.
|
|
2694
|
+
*
|
|
2695
|
+
* Implementation note: Angular's `InputSignal` and `InputSignalWithTransform`
|
|
2696
|
+
* use `InputSignalNode` in an invariant position, making them invariant in their
|
|
2697
|
+
* type parameters under TypeScript's structural system. `InputSignal<number>`
|
|
2698
|
+
* does NOT extend `InputSignal<unknown>`. We therefore use `any` in the filter
|
|
2699
|
+
* predicate — `any` is a two-way assignability wildcard that correctly subsumes
|
|
2700
|
+
* all concrete instantiations without widening the extracted value type. */
|
|
2701
|
+
type ComponentInputs<C> = {
|
|
2702
|
+
[K in keyof C as C[K] extends InputSignal<any> | InputSignalWithTransform<any, any> ? K : never]: InputValue<C[K]>;
|
|
2703
|
+
};
|
|
2704
|
+
/** STRICT: every prop the schema PRODUCES must be a declared input with an
|
|
2705
|
+
* assignable type. FLEXIBLE: the component may declare extra inputs the schema
|
|
2706
|
+
* doesn't fill. A schema key absent from `Inputs` maps to `never`, so its
|
|
2707
|
+
* (non-never) value fails assignment and the error pins to that prop.
|
|
2708
|
+
*
|
|
2709
|
+
* This mapped type is homomorphic over `keyof Out`, so it preserves the
|
|
2710
|
+
* optionality (`?`) of each schema prop. A consequence: an OPTIONAL schema prop
|
|
2711
|
+
* is accepted against a `required` component input — the compiler cannot know
|
|
2712
|
+
* the model will actually supply it. That residual case (required input not
|
|
2713
|
+
* guaranteed by the schema) is caught at runtime by the schema-readiness mount
|
|
2714
|
+
* gate, which holds the fallback until the streamed props validate. Compile
|
|
2715
|
+
* time blocks structural mismatches; runtime blocks missing-but-required props. */
|
|
2716
|
+
type CompatibleProps<Out, Inputs> = {
|
|
2717
|
+
[K in keyof Out]: K extends keyof Inputs ? Inputs[K] : never;
|
|
2718
|
+
};
|
|
2719
|
+
/** The accepted `component` parameter type for `view`/`ask`: the real component
|
|
2720
|
+
* `Type<C>` when the schema output is compatible, else a labelled error tuple
|
|
2721
|
+
* that surfaces both shapes in the compiler message.
|
|
2722
|
+
*
|
|
2723
|
+
* Implementation note: `C extends ...` (distributive over C) lets TypeScript
|
|
2724
|
+
* infer `C` from the `Type<C>` arm first, then verify the constraint. A bare
|
|
2725
|
+
* conditional on the param type blocks inference when C appears only on the
|
|
2726
|
+
* right-hand side of the inner `extends`. */
|
|
2727
|
+
type AcceptComponent<S extends StandardSchemaV1, C> = C extends (StandardSchemaInferOutput<S> extends CompatibleProps<StandardSchemaInferOutput<S>, ComponentInputs<C>> ? C : never) ? Type<C> : readonly [
|
|
2728
|
+
'Schema output is not assignable to this component\'s inputs',
|
|
2729
|
+
StandardSchemaInferOutput<S>,
|
|
2730
|
+
ComponentInputs<C>
|
|
2731
|
+
];
|
|
2732
|
+
/** Reverse helper: derive a component's input prop types FROM a schema, so a
|
|
2733
|
+
* component authored straight from the schema is guaranteed compatible. */
|
|
2734
|
+
type ViewProps<S extends StandardSchemaV1> = Prettify<StandardSchemaInferOutput<S>>;
|
|
2735
|
+
|
|
2736
|
+
/**
|
|
2737
|
+
* Declare an async function tool the model can call; its resolved return value
|
|
2738
|
+
* becomes the tool result shipped back to the model.
|
|
2739
|
+
*
|
|
2740
|
+
* @param description Natural-language description the model sees.
|
|
2741
|
+
* @param schema Standard Schema (e.g. a Zod object) for the arguments; the
|
|
2742
|
+
* handler's argument type is inferred from it.
|
|
2743
|
+
* @param handler Runs in the browser when the model calls the tool; its return
|
|
2744
|
+
* type `R` is carried on the resulting {@link FunctionToolDef}.
|
|
2745
|
+
* @returns A {@link FunctionToolDef} for inclusion in {@link tools}.
|
|
2746
|
+
* @example
|
|
2747
|
+
* ```ts
|
|
2748
|
+
* const move = action('Move a stop', z.object({ fromDay: z.number() }), (a) => a.fromDay);
|
|
2749
|
+
* const registry = tools({ move_stop: move });
|
|
2750
|
+
* ```
|
|
2751
|
+
*/
|
|
2752
|
+
declare function action<S extends StandardSchemaV1, R>(description: string, schema: S, handler: (args: StandardSchemaInferOutput<S>) => R | Promise<R>): FunctionToolDef<S, R>;
|
|
2753
|
+
/**
|
|
2754
|
+
* Render-only component tool — the model fills the component's props from the
|
|
2755
|
+
* schema's output; the tool call is auto-acknowledged once the component mounts.
|
|
2756
|
+
*
|
|
2757
|
+
* The component's signal inputs are checked against the schema output type
|
|
2758
|
+
* (strict-but-flexible: every schema key must be a declared input with an
|
|
2759
|
+
* assignable type; the component may declare extra inputs the schema doesn't fill).
|
|
2760
|
+
* Author the component with `ViewProps<typeof schema>` as the input type set to
|
|
2761
|
+
* guarantee the shapes stay aligned.
|
|
2762
|
+
*
|
|
2763
|
+
* @param description Natural-language description the model sees.
|
|
2764
|
+
* @param schema Standard Schema defining the props the model must supply.
|
|
2765
|
+
* @param component Angular component whose signal inputs must be compatible with
|
|
2766
|
+
* the schema output. A type-level error is reported here when they diverge.
|
|
2767
|
+
* @returns A {@link ViewToolDef} for inclusion in {@link tools}.
|
|
2768
|
+
* @example
|
|
2769
|
+
* ```ts
|
|
2770
|
+
* const schema = z.object({ label: z.string(), day: z.number() });
|
|
2771
|
+
* type Inputs = ViewProps<typeof schema>; // { label: string; day: number }
|
|
2772
|
+
*
|
|
2773
|
+
* \@Component({ ... })
|
|
2774
|
+
* class DayCardComponent {
|
|
2775
|
+
* label = input.required<string>();
|
|
2776
|
+
* day = input.required<number>();
|
|
2777
|
+
* }
|
|
2778
|
+
*
|
|
2779
|
+
* const dayCard = view('Show a day card', schema, DayCardComponent);
|
|
2780
|
+
* const registry = tools({ day_card: dayCard });
|
|
2781
|
+
* ```
|
|
2782
|
+
*/
|
|
2783
|
+
declare function view<S extends StandardSchemaV1, C>(description: string, schema: S, component: AcceptComponent<S, C>): ViewToolDef<S, C>;
|
|
2784
|
+
/**
|
|
2785
|
+
* Interactive (human-in-the-loop) component tool — the model fills the
|
|
2786
|
+
* component's props from the schema's output; the value the component emits
|
|
2787
|
+
* back to the framework becomes the tool result sent to the model.
|
|
2788
|
+
*
|
|
2789
|
+
* The component's signal inputs are checked against the schema output type
|
|
2790
|
+
* (strict-but-flexible: every schema key must be a declared input with an
|
|
2791
|
+
* assignable type; the component may declare extra inputs the schema doesn't
|
|
2792
|
+
* fill). Author the component with `ViewProps<typeof schema>` to derive input
|
|
2793
|
+
* prop types directly from the schema.
|
|
2794
|
+
*
|
|
2795
|
+
* @param description Natural-language description the model sees.
|
|
2796
|
+
* @param schema Standard Schema defining the props the model must supply.
|
|
2797
|
+
* @param component Angular component whose signal inputs must be compatible with
|
|
2798
|
+
* the schema output. A type-level error is reported here when they diverge.
|
|
2799
|
+
* @returns An {@link AskToolDef} for inclusion in {@link tools}.
|
|
2800
|
+
* @example
|
|
2801
|
+
* ```ts
|
|
2802
|
+
* const schema = z.object({ question: z.string(), options: z.array(z.string()) });
|
|
2803
|
+
* type Inputs = ViewProps<typeof schema>;
|
|
2804
|
+
*
|
|
2805
|
+
* \@Component({ ... })
|
|
2806
|
+
* class ChoiceCardComponent {
|
|
2807
|
+
* question = input.required<string>();
|
|
2808
|
+
* options = input.required<string[]>();
|
|
2809
|
+
* // Emits the chosen option back to the model.
|
|
2810
|
+
* }
|
|
2811
|
+
*
|
|
2812
|
+
* const choice = ask('Ask the user to choose', schema, ChoiceCardComponent);
|
|
2813
|
+
* const registry = tools({ pick_option: choice });
|
|
2814
|
+
* ```
|
|
2815
|
+
*/
|
|
2816
|
+
declare function ask<S extends StandardSchemaV1, C>(description: string, schema: S, component: AcceptComponent<S, C>): AskToolDef<S, C>;
|
|
2817
|
+
/**
|
|
2818
|
+
* Collect named client tools into a frozen, name-keyed registry.
|
|
2819
|
+
*
|
|
2820
|
+
* The overload is generic over the entire map (`const M`) so that each tool's
|
|
2821
|
+
* precise type ({@link FunctionToolDef}`<S,R>`, {@link ViewToolDef}`<S,C>`, or
|
|
2822
|
+
* {@link AskToolDef}`<S,C>`) and every literal key are preserved in the
|
|
2823
|
+
* {@link ClientToolRegistry} passed to `provideChat`. This lets downstream
|
|
2824
|
+
* consumers look up individual tools without losing generic information.
|
|
2825
|
+
*
|
|
2826
|
+
* @param map An object literal mapping tool names to tool definitions created
|
|
2827
|
+
* by {@link action}, {@link view}, or {@link ask}.
|
|
2828
|
+
* @returns A frozen `Readonly<M>` where `M` is the exact inferred map shape.
|
|
2829
|
+
* @example
|
|
2830
|
+
* ```ts
|
|
2831
|
+
* const move = action('Move a stop', z.object({ fromDay: z.number() }), (a) => a.fromDay);
|
|
2832
|
+
* const dayCard = view('Show a day card', z.object({ label: z.string() }), DayCardComponent);
|
|
2833
|
+
*
|
|
2834
|
+
* const registry = tools({ move_stop: move, day_card: dayCard });
|
|
2835
|
+
* // registry.move_stop is FunctionToolDef<...>
|
|
2836
|
+
* // registry.day_card is ViewToolDef<...>
|
|
2837
|
+
* ```
|
|
2838
|
+
*/
|
|
2839
|
+
declare function tools<const M extends Record<string, ClientToolDef>>(map: M): Readonly<M>;
|
|
2382
2840
|
|
|
2383
2841
|
/** Validate raw model args against a Standard Schema. */
|
|
2384
2842
|
declare function validateArgs(schema: StandardSchemaV1, args: unknown): Promise<{
|
|
@@ -2389,7 +2847,7 @@ declare function validateArgs(schema: StandardSchemaV1, args: unknown): Promise<
|
|
|
2389
2847
|
error: string;
|
|
2390
2848
|
}>;
|
|
2391
2849
|
/** Validate args, run the handler, and normalize the outcome to a ClientToolResult. */
|
|
2392
|
-
declare function executeFunctionTool(def:
|
|
2850
|
+
declare function executeFunctionTool(def: AnyFunctionToolDef, rawArgs: unknown): Promise<ClientToolResult>;
|
|
2393
2851
|
|
|
2394
2852
|
/**
|
|
2395
2853
|
* Watches the agent's pending client tool calls and auto-runs FUNCTION tools,
|
|
@@ -2411,13 +2869,12 @@ interface ClientToolsCoordinator {
|
|
|
2411
2869
|
}
|
|
2412
2870
|
/** Build the catalog spec list shipped to the model. */
|
|
2413
2871
|
declare function toClientToolSpecs(registry: ClientToolRegistry): ClientToolSpec[];
|
|
2414
|
-
declare function createClientToolsCoordinator(registry: ClientToolRegistry): ClientToolsCoordinator;
|
|
2415
2872
|
|
|
2416
2873
|
interface MockAgent extends Agent {
|
|
2417
2874
|
messages: WritableSignal<Message[]>;
|
|
2418
2875
|
status: WritableSignal<AgentStatus>;
|
|
2419
2876
|
isLoading: WritableSignal<boolean>;
|
|
2420
|
-
error: WritableSignal<
|
|
2877
|
+
error: WritableSignal<AgentError | undefined>;
|
|
2421
2878
|
toolCalls: WritableSignal<ToolCall[]>;
|
|
2422
2879
|
state: WritableSignal<Record<string, unknown>>;
|
|
2423
2880
|
interrupt?: WritableSignal<AgentInterrupt | undefined>;
|
|
@@ -2454,7 +2911,7 @@ interface MockAgentOptions {
|
|
|
2454
2911
|
messages?: Message[];
|
|
2455
2912
|
status?: AgentStatus;
|
|
2456
2913
|
isLoading?: boolean;
|
|
2457
|
-
error?:
|
|
2914
|
+
error?: AgentError;
|
|
2458
2915
|
toolCalls?: ToolCall[];
|
|
2459
2916
|
state?: Record<string, unknown>;
|
|
2460
2917
|
withInterrupt?: boolean;
|
|
@@ -2462,7 +2919,25 @@ interface MockAgentOptions {
|
|
|
2462
2919
|
history?: AgentCheckpoint[];
|
|
2463
2920
|
events$?: Observable<AgentEvent>;
|
|
2464
2921
|
}
|
|
2922
|
+
/**
|
|
2923
|
+
* Build an in-memory {@link Agent} for tests and stories — no transport, no
|
|
2924
|
+
* network. Every field is a writable signal so a test can drive UI states
|
|
2925
|
+
* (loading, error, interrupts, tool calls, subagents) deterministically.
|
|
2926
|
+
*
|
|
2927
|
+
* @param opts Initial values for the mock's signals; all optional.
|
|
2928
|
+
* @returns A {@link MockAgent} satisfying the full `Agent` contract.
|
|
2929
|
+
* @example
|
|
2930
|
+
* ```ts
|
|
2931
|
+
* const agent = mockAgent({
|
|
2932
|
+
* messages: [{ id: '1', role: 'assistant', content: 'Hi' }],
|
|
2933
|
+
* isLoading: true,
|
|
2934
|
+
* });
|
|
2935
|
+
* ```
|
|
2936
|
+
*/
|
|
2465
2937
|
declare function mockAgent(opts?: MockAgentOptions): MockAgent;
|
|
2466
2938
|
|
|
2467
|
-
|
|
2468
|
-
|
|
2939
|
+
/** Inferred argument type for a schema (alias of StandardSchemaInferOutput). */
|
|
2940
|
+
type ToolArgs<S extends StandardSchemaV1> = StandardSchemaInferOutput<S>;
|
|
2941
|
+
|
|
2942
|
+
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, 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, 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, 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, toAgentError, toClientToolSpecs, tools, validateArgs, view };
|
|
2943
|
+
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 };
|