@newheap/platform-ai-chat 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +294 -0
- package/admin/index.d.ts +294 -0
- package/fesm2022/newheap-platform-ai-chat-admin.mjs +785 -0
- package/fesm2022/newheap-platform-ai-chat-admin.mjs.map +1 -0
- package/fesm2022/newheap-platform-ai-chat-testing.mjs +911 -0
- package/fesm2022/newheap-platform-ai-chat-testing.mjs.map +1 -0
- package/fesm2022/newheap-platform-ai-chat.mjs +3103 -0
- package/fesm2022/newheap-platform-ai-chat.mjs.map +1 -0
- package/i18n/en.json +376 -0
- package/i18n/nl.json +376 -0
- package/index.d.ts +937 -0
- package/package.json +54 -0
- package/testing/index.d.ts +189 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,937 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { InjectionToken, Type, EnvironmentProviders, Signal, AfterViewInit, OnDestroy, PipeTransform } from '@angular/core';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { TranslationObject } from '@ngx-translate/core';
|
|
5
|
+
import { TemplatePortal } from '@angular/cdk/portal';
|
|
6
|
+
|
|
7
|
+
interface AssistantStatus {
|
|
8
|
+
enabled: boolean;
|
|
9
|
+
agents: AgentSummary[];
|
|
10
|
+
limits: {
|
|
11
|
+
maxMessageChars: number;
|
|
12
|
+
maxToolCallsPerTurn: number;
|
|
13
|
+
};
|
|
14
|
+
/** True when the caller also passes the admin policy and may use the `admin/*` endpoints. */
|
|
15
|
+
canAdminister: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface AgentSummary {
|
|
18
|
+
id: string;
|
|
19
|
+
version: number;
|
|
20
|
+
displayNameKey: string;
|
|
21
|
+
descriptionKey: string;
|
|
22
|
+
canMutate: boolean;
|
|
23
|
+
}
|
|
24
|
+
interface ConversationSummary {
|
|
25
|
+
id: string;
|
|
26
|
+
agentId: string;
|
|
27
|
+
title: string | null;
|
|
28
|
+
status: ConversationStatus;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
updatedAt: string;
|
|
31
|
+
}
|
|
32
|
+
interface Conversation extends ConversationSummary {
|
|
33
|
+
agentVersion: number;
|
|
34
|
+
messages: Message[];
|
|
35
|
+
pendingApproval: ApprovalPart | null;
|
|
36
|
+
}
|
|
37
|
+
type ConversationStatus = 'idle' | 'running' | 'waiting-for-approval' | 'failed' | 'archived';
|
|
38
|
+
interface Message {
|
|
39
|
+
id: string;
|
|
40
|
+
role: 'user' | 'assistant' | 'tool';
|
|
41
|
+
createdAt: string;
|
|
42
|
+
parts: MessagePart[];
|
|
43
|
+
}
|
|
44
|
+
type MessagePart = TextPart | ToolCallPart | ApprovalPart;
|
|
45
|
+
interface TextPart {
|
|
46
|
+
type: 'text';
|
|
47
|
+
text: string;
|
|
48
|
+
}
|
|
49
|
+
type ToolCallStatus = 'running' | 'succeeded' | 'failed' | 'awaiting-approval' | 'rejected';
|
|
50
|
+
interface ToolCallPart {
|
|
51
|
+
type: 'tool-call';
|
|
52
|
+
invocationId: string;
|
|
53
|
+
toolId: string;
|
|
54
|
+
toolVersion: number;
|
|
55
|
+
displayName: string;
|
|
56
|
+
status: ToolCallStatus;
|
|
57
|
+
argumentsPreview: string | null;
|
|
58
|
+
resultPreview: string | null;
|
|
59
|
+
resultCode: string | null;
|
|
60
|
+
}
|
|
61
|
+
type ApprovalStatus = 'pending' | 'approved' | 'rejected' | 'expired';
|
|
62
|
+
interface ApprovalPart {
|
|
63
|
+
type: 'approval';
|
|
64
|
+
approvalId: string;
|
|
65
|
+
proposalId: string;
|
|
66
|
+
proposalHash: string;
|
|
67
|
+
toolId: string;
|
|
68
|
+
summary: string;
|
|
69
|
+
argumentsPreview: string;
|
|
70
|
+
targets: string[];
|
|
71
|
+
expiresAt: string;
|
|
72
|
+
status: ApprovalStatus;
|
|
73
|
+
}
|
|
74
|
+
/** Response of `GET conversations?page=&itemsPerPage=`. */
|
|
75
|
+
interface ConversationPage {
|
|
76
|
+
items: ConversationSummary[];
|
|
77
|
+
total: number;
|
|
78
|
+
}
|
|
79
|
+
/** Body of `POST conversations`. */
|
|
80
|
+
interface CreateConversationRequest {
|
|
81
|
+
agentId: string;
|
|
82
|
+
title?: string;
|
|
83
|
+
}
|
|
84
|
+
/** An entity the user has open, for example `{ type: 'project', id: 'AA09027', label: 'Project AA09027' }`. */
|
|
85
|
+
interface ClientContextEntity {
|
|
86
|
+
/** Dash-case, for example `order-group`. */
|
|
87
|
+
type: string;
|
|
88
|
+
/** At most 64 characters. */
|
|
89
|
+
id: string;
|
|
90
|
+
/** At most 120 characters. */
|
|
91
|
+
label?: string | null;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* What the user has open when sending a message. Untrusted page data for the model:
|
|
95
|
+
* entity ids are search hints only and never grant access.
|
|
96
|
+
*/
|
|
97
|
+
interface ClientContext {
|
|
98
|
+
/** For example `/order-group/123`; at most 200 characters. */
|
|
99
|
+
route: string;
|
|
100
|
+
/** Page title; at most 120 characters. */
|
|
101
|
+
title?: string | null;
|
|
102
|
+
/** At most 5 entities. */
|
|
103
|
+
entities?: ClientContextEntity[];
|
|
104
|
+
}
|
|
105
|
+
/** Library name of the contract's `ClientContext`. */
|
|
106
|
+
type NhAssistantClientContext = ClientContext;
|
|
107
|
+
/** Body of `POST conversations/{id}/messages`. */
|
|
108
|
+
interface SendMessageRequest {
|
|
109
|
+
text: string;
|
|
110
|
+
clientMessageId: string;
|
|
111
|
+
/** Page context of this message; `null` when the user left it out. */
|
|
112
|
+
clientContext?: ClientContext | null;
|
|
113
|
+
}
|
|
114
|
+
type ApprovalDecision = 'approve' | 'reject';
|
|
115
|
+
/** Body of `POST conversations/{id}/approvals/{approvalId}/decide`. */
|
|
116
|
+
interface DecideApprovalRequest {
|
|
117
|
+
decision: ApprovalDecision;
|
|
118
|
+
expectedProposalHash: string;
|
|
119
|
+
reason?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface TurnStartedEvent {
|
|
123
|
+
turnId: string;
|
|
124
|
+
userMessageId: string;
|
|
125
|
+
assistantMessageId: string;
|
|
126
|
+
}
|
|
127
|
+
interface MessageDeltaEvent {
|
|
128
|
+
messageId: string;
|
|
129
|
+
text: string;
|
|
130
|
+
}
|
|
131
|
+
interface ToolStartedEvent {
|
|
132
|
+
invocationId: string;
|
|
133
|
+
toolId: string;
|
|
134
|
+
toolVersion: number;
|
|
135
|
+
displayName: string;
|
|
136
|
+
argumentsPreview: string | null;
|
|
137
|
+
}
|
|
138
|
+
interface ToolCompletedEvent {
|
|
139
|
+
invocationId: string;
|
|
140
|
+
status: 'succeeded' | 'failed';
|
|
141
|
+
resultCode: string | null;
|
|
142
|
+
resultPreview: string | null;
|
|
143
|
+
}
|
|
144
|
+
type ApprovalRequiredEvent = ApprovalPart;
|
|
145
|
+
type TurnCompletionStatus = 'completed' | 'waiting-for-approval' | 'cancelled' | 'failed';
|
|
146
|
+
interface TurnUsage {
|
|
147
|
+
inputTokens: number;
|
|
148
|
+
outputTokens: number;
|
|
149
|
+
toolCalls: number;
|
|
150
|
+
}
|
|
151
|
+
interface TurnCompletedEvent {
|
|
152
|
+
turnId: string;
|
|
153
|
+
status: TurnCompletionStatus;
|
|
154
|
+
usage: TurnUsage;
|
|
155
|
+
errorCode: string | null;
|
|
156
|
+
}
|
|
157
|
+
interface AssistantErrorEvent {
|
|
158
|
+
code: string;
|
|
159
|
+
messageKey: string;
|
|
160
|
+
}
|
|
161
|
+
/** Map from SSE event name to its data payload. */
|
|
162
|
+
interface NhAssistantSseEventMap {
|
|
163
|
+
'turn.started': TurnStartedEvent;
|
|
164
|
+
'message.delta': MessageDeltaEvent;
|
|
165
|
+
'tool.started': ToolStartedEvent;
|
|
166
|
+
'tool.completed': ToolCompletedEvent;
|
|
167
|
+
'approval.required': ApprovalRequiredEvent;
|
|
168
|
+
'turn.completed': TurnCompletedEvent;
|
|
169
|
+
'error': AssistantErrorEvent;
|
|
170
|
+
}
|
|
171
|
+
type NhAssistantSseEventType = keyof NhAssistantSseEventMap;
|
|
172
|
+
/** One parsed assistant event, discriminated by its SSE event name. */
|
|
173
|
+
type NhAssistantSseEvent = {
|
|
174
|
+
[K in NhAssistantSseEventType]: {
|
|
175
|
+
type: K;
|
|
176
|
+
data: NhAssistantSseEventMap[K];
|
|
177
|
+
};
|
|
178
|
+
}[NhAssistantSseEventType];
|
|
179
|
+
declare const NH_ASSISTANT_SSE_EVENT_TYPES: readonly NhAssistantSseEventType[];
|
|
180
|
+
/**
|
|
181
|
+
* Stable client-side failure codes. The client emits these as `error` events when the
|
|
182
|
+
* transport fails before the server could send its own `error` event.
|
|
183
|
+
*/
|
|
184
|
+
declare const NhAssistantClientErrorCodes: {
|
|
185
|
+
readonly network: "assistant-network";
|
|
186
|
+
readonly unauthenticated: "assistant-unauthenticated";
|
|
187
|
+
readonly forbidden: "assistant-forbidden";
|
|
188
|
+
readonly notFound: "assistant-not-found";
|
|
189
|
+
readonly conversationBusy: "assistant-conversation-busy";
|
|
190
|
+
readonly validation: "assistant-validation";
|
|
191
|
+
readonly versionConflict: "assistant-version-conflict";
|
|
192
|
+
readonly invalidResponse: "assistant-invalid-response";
|
|
193
|
+
readonly streamInterrupted: "assistant-stream-interrupted";
|
|
194
|
+
readonly server: "assistant-server";
|
|
195
|
+
};
|
|
196
|
+
type NhAssistantClientErrorCode = typeof NhAssistantClientErrorCodes[keyof typeof NhAssistantClientErrorCodes];
|
|
197
|
+
|
|
198
|
+
type AssistantStyle = 'default' | 'direct' | 'personal' | 'detailed';
|
|
199
|
+
type AssistantAddressForm = 'informal' | 'formal';
|
|
200
|
+
type AssistantResponseLength = 'short' | 'normal' | 'long';
|
|
201
|
+
interface AssistantPreferences {
|
|
202
|
+
style: AssistantStyle;
|
|
203
|
+
addressForm: AssistantAddressForm;
|
|
204
|
+
responseLength: AssistantResponseLength;
|
|
205
|
+
/** At most 1,000 characters. Steers style only; it never overrides the fixed rules. */
|
|
206
|
+
customInstructions: string | null;
|
|
207
|
+
}
|
|
208
|
+
interface ApplicationContext {
|
|
209
|
+
text: string;
|
|
210
|
+
version: number;
|
|
211
|
+
hash: string;
|
|
212
|
+
updatedAt: string;
|
|
213
|
+
updatedBy: string | null;
|
|
214
|
+
}
|
|
215
|
+
interface ApplicationContextVersion {
|
|
216
|
+
version: number;
|
|
217
|
+
hash: string;
|
|
218
|
+
updatedAt: string;
|
|
219
|
+
updatedBy: string | null;
|
|
220
|
+
}
|
|
221
|
+
/** Body of `PUT admin/context`. */
|
|
222
|
+
interface UpdateApplicationContextRequest {
|
|
223
|
+
text: string;
|
|
224
|
+
expectedVersion: number;
|
|
225
|
+
}
|
|
226
|
+
type ToolCatalogEffect = 'read-only' | 'idempotent-mutation' | 'mutation' | 'destructive';
|
|
227
|
+
interface ToolCatalogEntry {
|
|
228
|
+
id: string;
|
|
229
|
+
source: 'local' | 'bridge' | 'mcp';
|
|
230
|
+
effect: ToolCatalogEffect;
|
|
231
|
+
description: string;
|
|
232
|
+
}
|
|
233
|
+
/** Equals `NhAiAutonomyLevel`. */
|
|
234
|
+
type AssistantAutonomy = 'observe' | 'explain' | 'propose' | 'simulate' | 'execute';
|
|
235
|
+
interface AdminAgentInput {
|
|
236
|
+
id: string;
|
|
237
|
+
displayName: string;
|
|
238
|
+
description: string;
|
|
239
|
+
instructions: string;
|
|
240
|
+
toolSelectors: string[];
|
|
241
|
+
mcpServerIds: string[];
|
|
242
|
+
requiredPolicy: string | null;
|
|
243
|
+
autonomy: AssistantAutonomy;
|
|
244
|
+
isEnabled: boolean;
|
|
245
|
+
}
|
|
246
|
+
/** Body of `PUT admin/agents/{id}`. */
|
|
247
|
+
type UpdateAdminAgentRequest = AdminAgentInput & {
|
|
248
|
+
expectedVersion: number;
|
|
249
|
+
};
|
|
250
|
+
interface AdminAgent extends AdminAgentInput {
|
|
251
|
+
version: number;
|
|
252
|
+
source: 'code' | 'admin';
|
|
253
|
+
isOverridden: boolean;
|
|
254
|
+
instructionsHash: string;
|
|
255
|
+
updatedAt: string;
|
|
256
|
+
}
|
|
257
|
+
type McpAuthMode = 'none' | 'bearer' | 'api-key' | 'forward-user-token';
|
|
258
|
+
interface McpServerInput {
|
|
259
|
+
id: string;
|
|
260
|
+
displayName: string;
|
|
261
|
+
url: string;
|
|
262
|
+
authMode: McpAuthMode;
|
|
263
|
+
headerName: string | null;
|
|
264
|
+
/** Write-only. Omit to keep the stored secret, `""` to clear it. */
|
|
265
|
+
secret?: string | null;
|
|
266
|
+
requiredPolicy: string | null;
|
|
267
|
+
isEnabled: boolean;
|
|
268
|
+
}
|
|
269
|
+
interface McpServer {
|
|
270
|
+
id: string;
|
|
271
|
+
displayName: string;
|
|
272
|
+
url: string;
|
|
273
|
+
authMode: McpAuthMode;
|
|
274
|
+
headerName: string | null;
|
|
275
|
+
hasSecret: boolean;
|
|
276
|
+
requiredPolicy: string | null;
|
|
277
|
+
isEnabled: boolean;
|
|
278
|
+
lastSyncAt: string | null;
|
|
279
|
+
lastSyncStatus: 'ok' | 'failed' | null;
|
|
280
|
+
assignedAgentIds: string[];
|
|
281
|
+
}
|
|
282
|
+
interface McpServerTestResult {
|
|
283
|
+
ok: boolean;
|
|
284
|
+
code: string | null;
|
|
285
|
+
toolCount: number | null;
|
|
286
|
+
}
|
|
287
|
+
type McpToolEffect = 'read-only' | 'mutation';
|
|
288
|
+
type McpToolStatus = 'available' | 'schema-changed' | 'missing';
|
|
289
|
+
interface McpTool {
|
|
290
|
+
remoteName: string;
|
|
291
|
+
localId: string;
|
|
292
|
+
description: string;
|
|
293
|
+
descriptionOverride: string | null;
|
|
294
|
+
isEnabled: boolean;
|
|
295
|
+
effect: McpToolEffect;
|
|
296
|
+
status: McpToolStatus;
|
|
297
|
+
/** Remote annotation. Untrusted: shown as a hint only, never used as a default. */
|
|
298
|
+
readOnlyHint: boolean | null;
|
|
299
|
+
}
|
|
300
|
+
/** Body of `PUT admin/mcp-servers/{id}/tools/{remoteName}`. */
|
|
301
|
+
interface UpdateMcpToolRequest {
|
|
302
|
+
isEnabled: boolean;
|
|
303
|
+
effect: McpToolEffect;
|
|
304
|
+
descriptionOverride: string | null;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** Decides whether the current user may see and use the assistant. */
|
|
308
|
+
interface NhAssistantAccessPolicy {
|
|
309
|
+
canUse(): boolean | Observable<boolean>;
|
|
310
|
+
}
|
|
311
|
+
interface NhAssistantConfig {
|
|
312
|
+
/** Base URL of the assistant endpoints, for example `environment.api.baseUrl + '/assistant'`. */
|
|
313
|
+
apiBaseUrl: string;
|
|
314
|
+
/**
|
|
315
|
+
* Returns the caller's bearer token, or null when the request should be anonymous. It runs
|
|
316
|
+
* in the injection context of the assistant scope before every request, so it may call
|
|
317
|
+
* `inject(...)`, for example `() => inject(MyAuthService).getAuthorization()?.token ?? null`.
|
|
318
|
+
*/
|
|
319
|
+
getAccessToken: () => string | null | Promise<string | null>;
|
|
320
|
+
/**
|
|
321
|
+
* Returns what the user has open, sent with each message as untrusted page context.
|
|
322
|
+
* Runs in the assistant's injection context when the panel opens and before every
|
|
323
|
+
* message, like `getAccessToken`. The library validates and truncates the result; a
|
|
324
|
+
* failing getter or an invalid shape only leaves the context out. Default: none.
|
|
325
|
+
*/
|
|
326
|
+
getPageContext?: () => ClientContext | null | Promise<ClientContext | null>;
|
|
327
|
+
/** Injectable access policy. Default: always allowed. */
|
|
328
|
+
accessPolicy?: Type<NhAssistantAccessPolicy>;
|
|
329
|
+
/** Agent selected when the user has not chosen one. Default: the first agent the server lists. */
|
|
330
|
+
defaultAgentId?: string;
|
|
331
|
+
/** `'bundled'` merges the library's `en` and `nl` texts into `TranslateService`; `'host'` leaves translations to the host. Default `'bundled'`. */
|
|
332
|
+
translations?: 'bundled' | 'host';
|
|
333
|
+
/**
|
|
334
|
+
* Router link of the host's assistant administration page. The panel shows a link to it
|
|
335
|
+
* only when the server reports `canAdminister`. Default: no link.
|
|
336
|
+
*/
|
|
337
|
+
adminRoute?: string | any[];
|
|
338
|
+
/** Renders assistant text as sanitized Markdown. Default `{ enabled: true }`. */
|
|
339
|
+
markdown?: {
|
|
340
|
+
enabled: boolean;
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
declare const NH_ASSISTANT_CONFIG: InjectionToken<NhAssistantConfig>;
|
|
344
|
+
declare const NH_ASSISTANT_ACCESS_POLICY: InjectionToken<NhAssistantAccessPolicy>;
|
|
345
|
+
/** The `fetch` function type the assistant client uses. */
|
|
346
|
+
type NhAssistantFetch = (input: string, init: RequestInit) => Promise<Response>;
|
|
347
|
+
/**
|
|
348
|
+
* Transport used by the assistant client. It is deliberately independent of the host's
|
|
349
|
+
* `HttpClient` and interceptors, because streaming responses need `fetch` and the access
|
|
350
|
+
* token comes from `NhAssistantConfig.getAccessToken`. Tests and the mock API from
|
|
351
|
+
* `@newheap/platform-ai-chat/testing` replace it.
|
|
352
|
+
*/
|
|
353
|
+
declare const NH_ASSISTANT_FETCH: InjectionToken<NhAssistantFetch>;
|
|
354
|
+
/** Default policy: every user who can reach the host may use the assistant. */
|
|
355
|
+
declare class NhAssistantAllowAllAccessPolicy implements NhAssistantAccessPolicy {
|
|
356
|
+
canUse(): boolean;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/**
|
|
360
|
+
* Registers the assistant client, store and panel for one application or route scope.
|
|
361
|
+
* Call it once in the root providers; a route may call it again to host an isolated
|
|
362
|
+
* assistant with its own configuration.
|
|
363
|
+
*/
|
|
364
|
+
declare function provideNhAssistant(config: NhAssistantConfig): EnvironmentProviders;
|
|
365
|
+
|
|
366
|
+
/** The library's own translation bundles, keyed by language. All keys live under `nh-assistant.`. */
|
|
367
|
+
declare const NH_ASSISTANT_TRANSLATIONS: Readonly<Record<'en' | 'nl', TranslationObject>>;
|
|
368
|
+
/**
|
|
369
|
+
* Merges the bundled texts into `TranslateService` whenever the host loads or replaces a
|
|
370
|
+
* language. Host loaders never lose the library texts, the library never pre-empts the
|
|
371
|
+
* host loader, and keys the host defines under `nh-assistant.` (agent names, overrides)
|
|
372
|
+
* win over the bundle. Languages without a bundle receive the English texts.
|
|
373
|
+
*/
|
|
374
|
+
declare class NhAssistantTranslationMerger {
|
|
375
|
+
private readonly translate;
|
|
376
|
+
private readonly destroyRef;
|
|
377
|
+
private started;
|
|
378
|
+
start(): void;
|
|
379
|
+
private ensure;
|
|
380
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantTranslationMerger, never>;
|
|
381
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<NhAssistantTranslationMerger>;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/** One raw server-sent event before its data is interpreted. */
|
|
385
|
+
interface NhAssistantRawSseMessage {
|
|
386
|
+
event: string;
|
|
387
|
+
data: string;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* Incremental parser for the `text/event-stream` format.
|
|
391
|
+
*
|
|
392
|
+
* Feed decoded text chunks in arrival order. Chunks may split lines, fields and line
|
|
393
|
+
* terminators anywhere. Comment lines (starting with `:`, such as the `: keep-alive`
|
|
394
|
+
* heartbeat) are ignored; `id` and `retry` fields are accepted and ignored. An event is
|
|
395
|
+
* dispatched at the empty line that terminates it. An unterminated event at the end of
|
|
396
|
+
* the stream is discarded, as the SSE specification requires.
|
|
397
|
+
*/
|
|
398
|
+
declare class NhAssistantSseParser {
|
|
399
|
+
private buffer;
|
|
400
|
+
private eventName;
|
|
401
|
+
private dataLines;
|
|
402
|
+
push(chunk: string): NhAssistantRawSseMessage[];
|
|
403
|
+
/** Signals the end of the stream and returns an event that a trailing CR completed. */
|
|
404
|
+
end(): NhAssistantRawSseMessage[];
|
|
405
|
+
private processLine;
|
|
406
|
+
private dispatch;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** A failed JSON request of the assistant API. Carries a stable code, never response text. */
|
|
410
|
+
declare class NhAssistantApiError extends Error {
|
|
411
|
+
readonly status: number;
|
|
412
|
+
readonly code: string;
|
|
413
|
+
readonly messageKey: string;
|
|
414
|
+
constructor(status: number, code: string, messageKey: string);
|
|
415
|
+
}
|
|
416
|
+
/** Translation key that belongs to a failure code. */
|
|
417
|
+
declare function nhAssistantErrorMessageKey(code: string): string;
|
|
418
|
+
/** Maps an HTTP status of the assistant API to a stable client failure code. */
|
|
419
|
+
declare function nhAssistantCodeForStatus(status: number): string;
|
|
420
|
+
/** Status-specific codes that replace the generic mapping for one endpoint. */
|
|
421
|
+
type NhAssistantStatusCodes = Partial<Record<number, string>>;
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* Client for the assistant HTTP API. JSON endpoints return cold observables that abort
|
|
425
|
+
* their request on unsubscribe. Streaming endpoints emit every contract event and complete
|
|
426
|
+
* after `turn.completed` or `error`; transport failures become an `error` event with a
|
|
427
|
+
* client failure code instead of an observable error.
|
|
428
|
+
*/
|
|
429
|
+
declare class NhAssistantApiService {
|
|
430
|
+
private readonly transport;
|
|
431
|
+
status(): Observable<AssistantStatus>;
|
|
432
|
+
agents(): Observable<AgentSummary[]>;
|
|
433
|
+
listConversations(page?: number, itemsPerPage?: number): Observable<ConversationPage>;
|
|
434
|
+
createConversation(request: CreateConversationRequest): Observable<Conversation>;
|
|
435
|
+
getConversation(conversationId: string): Observable<Conversation>;
|
|
436
|
+
deleteConversation(conversationId: string): Observable<void>;
|
|
437
|
+
sendMessage(conversationId: string, request: SendMessageRequest): Observable<NhAssistantSseEvent>;
|
|
438
|
+
decideApproval(conversationId: string, approvalId: string, request: DecideApprovalRequest): Observable<NhAssistantSseEvent>;
|
|
439
|
+
cancel(conversationId: string): Observable<void>;
|
|
440
|
+
/** The caller's own assistant preferences. */
|
|
441
|
+
getPreferences(): Observable<AssistantPreferences>;
|
|
442
|
+
/** Replaces the caller's own assistant preferences and returns the stored values. */
|
|
443
|
+
updatePreferences(preferences: AssistantPreferences): Observable<AssistantPreferences>;
|
|
444
|
+
private requestStream;
|
|
445
|
+
private executeStream;
|
|
446
|
+
private readStream;
|
|
447
|
+
private emitClientError;
|
|
448
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantApiService, never>;
|
|
449
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<NhAssistantApiService>;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Client for the assistant administration endpoints (`admin/*`). The server requires the
|
|
454
|
+
* access policy and the admin policy; show the administration only when
|
|
455
|
+
* `NhAssistantStore.canAdminister()` is true. Failures error with `NhAssistantApiError`.
|
|
456
|
+
* Secrets are write-only: `McpServer` only reports `hasSecret`.
|
|
457
|
+
*/
|
|
458
|
+
declare class NhAssistantAdminApiService {
|
|
459
|
+
private readonly transport;
|
|
460
|
+
getContext(): Observable<ApplicationContext>;
|
|
461
|
+
/** Saves a new context version; fails with `assistant-version-conflict` when `expectedVersion` is stale. */
|
|
462
|
+
updateContext(request: UpdateApplicationContextRequest): Observable<ApplicationContext>;
|
|
463
|
+
getContextVersions(): Observable<ApplicationContextVersion[]>;
|
|
464
|
+
/** Local, bridge and MCP tools, for choosing tool selectors. */
|
|
465
|
+
getTools(): Observable<ToolCatalogEntry[]>;
|
|
466
|
+
getAgents(): Observable<AdminAgent[]>;
|
|
467
|
+
createAgent(input: AdminAgentInput): Observable<AdminAgent>;
|
|
468
|
+
updateAgent(agentId: string, request: UpdateAdminAgentRequest): Observable<AdminAgent>;
|
|
469
|
+
/** Restores a code agent to its definition in code. */
|
|
470
|
+
resetAgent(agentId: string): Observable<AdminAgent>;
|
|
471
|
+
/** Deletes an admin agent. Code agents cannot be deleted; disable them instead. */
|
|
472
|
+
deleteAgent(agentId: string): Observable<void>;
|
|
473
|
+
getMcpServers(): Observable<McpServer[]>;
|
|
474
|
+
createMcpServer(input: McpServerInput): Observable<McpServer>;
|
|
475
|
+
/** Omit `secret` to keep the stored secret; send `""` to clear it. */
|
|
476
|
+
updateMcpServer(serverId: string, input: McpServerInput): Observable<McpServer>;
|
|
477
|
+
deleteMcpServer(serverId: string): Observable<void>;
|
|
478
|
+
testMcpServer(serverId: string): Observable<McpServerTestResult>;
|
|
479
|
+
/** Reads the remote tool list. New tools start disabled; a changed input schema disables a tool. */
|
|
480
|
+
syncMcpServer(serverId: string): Observable<McpTool[]>;
|
|
481
|
+
getMcpTools(serverId: string): Observable<McpTool[]>;
|
|
482
|
+
updateMcpTool(serverId: string, remoteName: string, request: UpdateMcpToolRequest): Observable<McpTool>;
|
|
483
|
+
private request;
|
|
484
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantAdminApiService, never>;
|
|
485
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<NhAssistantAdminApiService>;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Applies one assistant event to a conversation and returns the new conversation.
|
|
490
|
+
* The input is never mutated, so the result can be stored in a signal directly.
|
|
491
|
+
*
|
|
492
|
+
* @param clientMessageId id of the optimistic user message of the current turn; its id is
|
|
493
|
+
* replaced by the server's `userMessageId` when `turn.started` arrives.
|
|
494
|
+
*/
|
|
495
|
+
declare function applyNhAssistantEvent(conversation: Conversation, event: NhAssistantSseEvent, clientMessageId?: string): Conversation;
|
|
496
|
+
/** Records the user's approval decision locally until the server state is reloaded. */
|
|
497
|
+
declare function applyNhAssistantApprovalDecision(conversation: Conversation, approvalId: string, decision: 'approve' | 'reject'): Conversation;
|
|
498
|
+
|
|
499
|
+
/** Limits of the page context (contract 15.2). */
|
|
500
|
+
declare const NH_ASSISTANT_PAGE_CONTEXT_LIMITS: {
|
|
501
|
+
readonly route: 200;
|
|
502
|
+
readonly title: 120;
|
|
503
|
+
readonly entities: 5;
|
|
504
|
+
readonly entityId: 64;
|
|
505
|
+
readonly entityLabel: 120;
|
|
506
|
+
};
|
|
507
|
+
/**
|
|
508
|
+
* Validates host-provided page context and truncates it to the contract limits.
|
|
509
|
+
* Returns null for an invalid shape (not an object or no route), so the message is sent
|
|
510
|
+
* without page context. Route, title and labels are truncated; entities beyond five are
|
|
511
|
+
* dropped, and entities with a type that is not dash-case, an empty id or an id longer
|
|
512
|
+
* than 64 characters are dropped because a truncated id would point at another entity.
|
|
513
|
+
*/
|
|
514
|
+
declare function normalizeNhAssistantClientContext(value: unknown): ClientContext | null;
|
|
515
|
+
/** Short text for the page-context chip: the first entity's label, the title or the route. */
|
|
516
|
+
declare function describeNhAssistantClientContext(context: ClientContext): string;
|
|
517
|
+
|
|
518
|
+
/** A user-facing assistant failure: a stable code and a translation key, never raw server text. */
|
|
519
|
+
interface NhAssistantError {
|
|
520
|
+
code: string;
|
|
521
|
+
messageKey: string;
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Signal-based state of one assistant scope: availability, agents, the conversation list
|
|
525
|
+
* and the active conversation with its streamed turn.
|
|
526
|
+
*/
|
|
527
|
+
declare class NhAssistantStore {
|
|
528
|
+
private readonly api;
|
|
529
|
+
private readonly config;
|
|
530
|
+
private readonly injector;
|
|
531
|
+
private readonly accessPolicy;
|
|
532
|
+
private readonly accessGrantedState;
|
|
533
|
+
private readonly statusState;
|
|
534
|
+
private readonly statusLoadingState;
|
|
535
|
+
private readonly selectedAgentIdState;
|
|
536
|
+
private readonly conversationsState;
|
|
537
|
+
private readonly conversationsTotalState;
|
|
538
|
+
private readonly conversationsLoadingState;
|
|
539
|
+
private readonly activeConversationState;
|
|
540
|
+
private readonly conversationLoadingState;
|
|
541
|
+
private readonly streamingState;
|
|
542
|
+
private readonly decidingState;
|
|
543
|
+
private readonly errorState;
|
|
544
|
+
private readonly lastUsageState;
|
|
545
|
+
private readonly restoredDraftState;
|
|
546
|
+
private readonly pageContextState;
|
|
547
|
+
private readonly pageContextExcludedState;
|
|
548
|
+
private accessSubscription?;
|
|
549
|
+
private streamSubscription?;
|
|
550
|
+
private cancelTimer?;
|
|
551
|
+
private initialization?;
|
|
552
|
+
/** True when the access policy allows the user and the server reports the assistant as enabled. */
|
|
553
|
+
readonly enabled: _angular_core.Signal<boolean>;
|
|
554
|
+
readonly accessGranted: _angular_core.Signal<boolean | null>;
|
|
555
|
+
/** True when the assistant is enabled and the server reports that the caller passes the admin policy. */
|
|
556
|
+
readonly canAdminister: _angular_core.Signal<boolean>;
|
|
557
|
+
readonly statusLoading: _angular_core.Signal<boolean>;
|
|
558
|
+
readonly limits: _angular_core.Signal<{
|
|
559
|
+
maxMessageChars: number;
|
|
560
|
+
maxToolCallsPerTurn: number;
|
|
561
|
+
} | null>;
|
|
562
|
+
readonly agents: _angular_core.Signal<AgentSummary[]>;
|
|
563
|
+
readonly selectedAgentId: _angular_core.Signal<string | null>;
|
|
564
|
+
readonly selectedAgent: _angular_core.Signal<AgentSummary | null>;
|
|
565
|
+
readonly conversations: _angular_core.Signal<ConversationSummary[]>;
|
|
566
|
+
readonly conversationsTotal: _angular_core.Signal<number>;
|
|
567
|
+
readonly conversationsLoading: _angular_core.Signal<boolean>;
|
|
568
|
+
readonly activeConversation: _angular_core.Signal<Conversation | null>;
|
|
569
|
+
readonly conversationLoading: _angular_core.Signal<boolean>;
|
|
570
|
+
readonly streaming: _angular_core.Signal<boolean>;
|
|
571
|
+
readonly pendingApproval: _angular_core.Signal<ApprovalPart | null>;
|
|
572
|
+
readonly deciding: _angular_core.Signal<boolean>;
|
|
573
|
+
readonly error: _angular_core.Signal<NhAssistantError | null>;
|
|
574
|
+
readonly lastUsage: _angular_core.Signal<TurnUsage | null>;
|
|
575
|
+
/** Text of a message the server did not accept, so the composer can offer it again. */
|
|
576
|
+
readonly restoredDraft: _angular_core.Signal<string | null>;
|
|
577
|
+
/** Page context that the next message would send, for the transparency chip. */
|
|
578
|
+
readonly pageContext: _angular_core.Signal<ClientContext | null>;
|
|
579
|
+
/** True when the user left the page context out of the next message. */
|
|
580
|
+
readonly pageContextExcluded: _angular_core.Signal<boolean>;
|
|
581
|
+
/** True while the user can send: enabled, an agent is chosen and no turn runs or waits. */
|
|
582
|
+
readonly canSend: _angular_core.Signal<boolean>;
|
|
583
|
+
constructor();
|
|
584
|
+
/** Evaluates the access policy and loads the server status once. Safe to call repeatedly. */
|
|
585
|
+
initialize(): Promise<void>;
|
|
586
|
+
/** Reloads the server status, for example after the host changed the signed-in user. */
|
|
587
|
+
reloadStatus(): Promise<void>;
|
|
588
|
+
refreshConversations(): Promise<void>;
|
|
589
|
+
/** Chooses the agent for the next new conversation. Switching away from the active conversation's agent starts a new one. */
|
|
590
|
+
selectAgent(agentId: string): void;
|
|
591
|
+
/** Leaves the active conversation; the next message creates a new one. */
|
|
592
|
+
startNewConversation(): void;
|
|
593
|
+
openConversation(conversationId: string): Promise<void>;
|
|
594
|
+
deleteConversation(conversationId: string): Promise<void>;
|
|
595
|
+
/**
|
|
596
|
+
* Sends a user message. Creates a conversation with the selected agent when none is
|
|
597
|
+
* active, shows the message optimistically and applies the streamed events.
|
|
598
|
+
* Resolves `false` when the message was not accepted.
|
|
599
|
+
*/
|
|
600
|
+
send(text: string): Promise<boolean>;
|
|
601
|
+
/** Approves or rejects the pending approval. Ignores repeated calls while a decision is in flight. */
|
|
602
|
+
decide(decision: ApprovalDecision, reason?: string): void;
|
|
603
|
+
/** Asks the server to stop the running turn or to abandon a waiting approval. */
|
|
604
|
+
cancel(): Promise<void>;
|
|
605
|
+
clearError(): void;
|
|
606
|
+
/** Reads the host's page context again so the chip shows what the next message sends. */
|
|
607
|
+
refreshPageContext(): Promise<void>;
|
|
608
|
+
/** Leaves the page context out of the next message only, or includes it again. */
|
|
609
|
+
setPageContextExcluded(excluded: boolean): void;
|
|
610
|
+
/** Returns and clears the draft of a message that was not accepted. */
|
|
611
|
+
consumeRestoredDraft(): string | null;
|
|
612
|
+
/**
|
|
613
|
+
* Page context for one message: `undefined` omits the field (no getter, getter failed or
|
|
614
|
+
* invalid shape), `null` sends an explicit "none" (no context or left out by the user).
|
|
615
|
+
*/
|
|
616
|
+
private contextForMessage;
|
|
617
|
+
private readPageContext;
|
|
618
|
+
private startInitialization;
|
|
619
|
+
private createConversation;
|
|
620
|
+
private runStream;
|
|
621
|
+
private applyEvent;
|
|
622
|
+
private afterTurn;
|
|
623
|
+
private reloadActiveConversation;
|
|
624
|
+
private updateActive;
|
|
625
|
+
private removeMessage;
|
|
626
|
+
private selectInitialAgent;
|
|
627
|
+
private setError;
|
|
628
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantStore, never>;
|
|
629
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<NhAssistantStore>;
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
/** Drawer width on wider screens; below the mobile breakpoint the panel fills the screen. */
|
|
633
|
+
declare const NH_ASSISTANT_PANEL_WIDTH = "420px";
|
|
634
|
+
declare const NH_ASSISTANT_PANEL_MOBILE_QUERY = "(max-width: 599.98px)";
|
|
635
|
+
/**
|
|
636
|
+
* Opens and closes the assistant panel as a CDK overlay drawer on the right edge.
|
|
637
|
+
* `nh-assistant-panel` registers its content once; any component can then open the panel,
|
|
638
|
+
* optionally on a specific conversation. Escape closes the panel and focus returns to the
|
|
639
|
+
* element that opened it.
|
|
640
|
+
*/
|
|
641
|
+
declare class NhAssistantPanelService {
|
|
642
|
+
private readonly overlay;
|
|
643
|
+
private readonly store;
|
|
644
|
+
private readonly injector;
|
|
645
|
+
private readonly document;
|
|
646
|
+
private readonly breakpoints;
|
|
647
|
+
private readonly openState;
|
|
648
|
+
private overlayRef?;
|
|
649
|
+
private portal?;
|
|
650
|
+
private subscriptions;
|
|
651
|
+
private returnFocusTo;
|
|
652
|
+
readonly isOpen: Signal<boolean>;
|
|
653
|
+
constructor();
|
|
654
|
+
open(conversationId?: string): void;
|
|
655
|
+
close(): void;
|
|
656
|
+
toggle(): void;
|
|
657
|
+
/** Called by `nh-assistant-panel`; hosts should place that component once instead. */
|
|
658
|
+
registerPanel(portal: TemplatePortal): void;
|
|
659
|
+
unregisterPanel(portal: TemplatePortal): void;
|
|
660
|
+
private attach;
|
|
661
|
+
private ensureOverlay;
|
|
662
|
+
private updateSize;
|
|
663
|
+
private dispose;
|
|
664
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantPanelService, never>;
|
|
665
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<NhAssistantPanelService>;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
type NhAssistantIconName = 'assistant' | 'close' | 'send' | 'stop' | 'plus' | 'list' | 'trash' | 'tool' | 'check' | 'x' | 'warning' | 'chevron-down' | 'clock' | 'settings' | 'admin' | 'edit' | 'refresh' | 'link' | 'page';
|
|
669
|
+
/**
|
|
670
|
+
* Optional icon classes of the host's icon library, for example `{ close: 'ph ph-x' }`.
|
|
671
|
+
* Icons without a class use the library's small built-in outline glyphs.
|
|
672
|
+
*/
|
|
673
|
+
declare const NH_ASSISTANT_ICONS: InjectionToken<Partial<Record<NhAssistantIconName, string>>>;
|
|
674
|
+
/** Decorative icon. The surrounding control provides the accessible name. */
|
|
675
|
+
declare class NhAssistantIconComponent {
|
|
676
|
+
private readonly icons;
|
|
677
|
+
readonly name: _angular_core.InputSignal<NhAssistantIconName>;
|
|
678
|
+
readonly iconClass: _angular_core.Signal<string | null>;
|
|
679
|
+
readonly path: _angular_core.Signal<string>;
|
|
680
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantIconComponent, never>;
|
|
681
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantIconComponent, "nh-assistant-icon", never, { "name": { "alias": "name"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/**
|
|
685
|
+
* Header button that opens the assistant panel. It renders nothing while the assistant is
|
|
686
|
+
* disabled on the server or the access policy denies the user. A badge marks a conversation
|
|
687
|
+
* that waits for approval. Projected content replaces the default icon.
|
|
688
|
+
*/
|
|
689
|
+
declare class NhAssistantLauncherComponent {
|
|
690
|
+
readonly store: NhAssistantStore;
|
|
691
|
+
readonly panel: NhAssistantPanelService;
|
|
692
|
+
readonly waitingForApproval: _angular_core.Signal<boolean>;
|
|
693
|
+
readonly label: _angular_core.Signal<"nh-assistant.launcher.close" | "nh-assistant.launcher.open">;
|
|
694
|
+
constructor();
|
|
695
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantLauncherComponent, never>;
|
|
696
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantLauncherComponent, "nh-assistant-launcher", never, {}, {}, never, ["*"], true, never>;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* The assistant drawer. Place it once in the application layout; it renders nothing in
|
|
701
|
+
* place and appears as an overlay when `NhAssistantPanelService.open()` is called.
|
|
702
|
+
*/
|
|
703
|
+
declare class NhAssistantPanelComponent implements AfterViewInit, OnDestroy {
|
|
704
|
+
readonly store: NhAssistantStore;
|
|
705
|
+
readonly panel: NhAssistantPanelService;
|
|
706
|
+
private readonly config;
|
|
707
|
+
private readonly viewContainerRef;
|
|
708
|
+
private readonly router;
|
|
709
|
+
private readonly drawer;
|
|
710
|
+
private portal?;
|
|
711
|
+
readonly titleId: string;
|
|
712
|
+
readonly markdown: boolean;
|
|
713
|
+
readonly showConversations: _angular_core.WritableSignal<boolean>;
|
|
714
|
+
readonly showPreferences: _angular_core.WritableSignal<boolean>;
|
|
715
|
+
readonly adminRoute: string | any[] | null;
|
|
716
|
+
readonly conversation: _angular_core.Signal<Conversation | null>;
|
|
717
|
+
private readonly conversationId;
|
|
718
|
+
readonly messages: _angular_core.Signal<Message[]>;
|
|
719
|
+
readonly closed: _angular_core.Signal<boolean>;
|
|
720
|
+
readonly busy: _angular_core.Signal<boolean>;
|
|
721
|
+
readonly composerDisabled: _angular_core.Signal<boolean>;
|
|
722
|
+
readonly errorKeys: _angular_core.Signal<string[]>;
|
|
723
|
+
constructor();
|
|
724
|
+
ngAfterViewInit(): void;
|
|
725
|
+
ngOnDestroy(): void;
|
|
726
|
+
refreshPageContext(): void;
|
|
727
|
+
describeContext(context: ClientContext): string;
|
|
728
|
+
toggleConversations(): void;
|
|
729
|
+
togglePreferences(): void;
|
|
730
|
+
newConversation(): void;
|
|
731
|
+
openConversation(conversationId: string): void;
|
|
732
|
+
deleteConversation(conversationId: string): void;
|
|
733
|
+
send(text: string): void;
|
|
734
|
+
decide(decision: ApprovalDecision): void;
|
|
735
|
+
cancel(): void;
|
|
736
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantPanelComponent, never>;
|
|
737
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantPanelComponent, "nh-assistant-panel", never, {}, {}, never, never, true, never>;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/** The user's conversations with loading and empty states; selecting one opens it. */
|
|
741
|
+
declare class NhAssistantConversationListComponent {
|
|
742
|
+
readonly conversations: _angular_core.InputSignal<readonly ConversationSummary[]>;
|
|
743
|
+
readonly total: _angular_core.InputSignal<number>;
|
|
744
|
+
readonly activeConversationId: _angular_core.InputSignal<string | null>;
|
|
745
|
+
readonly loading: _angular_core.InputSignal<boolean>;
|
|
746
|
+
readonly disabled: _angular_core.InputSignal<boolean>;
|
|
747
|
+
readonly conversationSelect: _angular_core.OutputEmitterRef<string>;
|
|
748
|
+
readonly conversationDelete: _angular_core.OutputEmitterRef<string>;
|
|
749
|
+
readonly conversationCreate: _angular_core.OutputEmitterRef<void>;
|
|
750
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantConversationListComponent, never>;
|
|
751
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantConversationListComponent, "nh-assistant-conversation-list", never, { "conversations": { "alias": "conversations"; "required": true; "isSignal": true; }; "total": { "alias": "total"; "required": false; "isSignal": true; }; "activeConversationId": { "alias": "activeConversationId"; "required": false; "isSignal": true; }; "loading": { "alias": "loading"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "conversationSelect": "conversationSelect"; "conversationDelete": "conversationDelete"; "conversationCreate": "conversationCreate"; }, never, never, true, never>;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/** Above this number of messages the thread renders through CDK virtual scrolling. */
|
|
755
|
+
declare const NH_ASSISTANT_VIRTUAL_SCROLL_THRESHOLD = 200;
|
|
756
|
+
/**
|
|
757
|
+
* The messages of a conversation as a live log. Assistant text renders as sanitized
|
|
758
|
+
* Markdown, tool calls and approvals as cards. The thread follows new content while the
|
|
759
|
+
* user is at the bottom.
|
|
760
|
+
*/
|
|
761
|
+
declare class NhAssistantThreadComponent {
|
|
762
|
+
private readonly injector;
|
|
763
|
+
readonly messages: _angular_core.InputSignal<readonly Message[]>;
|
|
764
|
+
readonly streaming: _angular_core.InputSignal<boolean>;
|
|
765
|
+
readonly deciding: _angular_core.InputSignal<boolean>;
|
|
766
|
+
readonly markdown: _angular_core.InputSignal<boolean>;
|
|
767
|
+
readonly approvalDecision: _angular_core.OutputEmitterRef<ApprovalDecision>;
|
|
768
|
+
readonly virtualThreshold = 200;
|
|
769
|
+
readonly virtual: _angular_core.Signal<boolean>;
|
|
770
|
+
readonly working: _angular_core.Signal<boolean>;
|
|
771
|
+
private readonly scroller;
|
|
772
|
+
private readonly viewport;
|
|
773
|
+
constructor();
|
|
774
|
+
trackMessage(_index: number, message: Message): string;
|
|
775
|
+
private scrollElement;
|
|
776
|
+
private scrollToEnd;
|
|
777
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantThreadComponent, never>;
|
|
778
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantThreadComponent, "nh-assistant-thread", never, { "messages": { "alias": "messages"; "required": true; "isSignal": true; }; "streaming": { "alias": "streaming"; "required": false; "isSignal": true; }; "deciding": { "alias": "deciding"; "required": false; "isSignal": true; }; "markdown": { "alias": "markdown"; "required": false; "isSignal": true; }; }, { "approvalDecision": "approvalDecision"; }, never, never, true, never>;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Message input. Enter sends, Shift+Enter inserts a new line. While the assistant runs
|
|
783
|
+
* the send button becomes a stop button.
|
|
784
|
+
*/
|
|
785
|
+
declare class NhAssistantComposerComponent {
|
|
786
|
+
/** Disables typing and sending, for example while a turn runs or waits for approval. */
|
|
787
|
+
readonly disabled: _angular_core.InputSignal<boolean>;
|
|
788
|
+
/** Shows the stop button instead of the send button. */
|
|
789
|
+
readonly busy: _angular_core.InputSignal<boolean>;
|
|
790
|
+
readonly maxLength: _angular_core.InputSignal<number | null>;
|
|
791
|
+
/** Text to put back into the input, for example a message the server did not accept. */
|
|
792
|
+
readonly restore: _angular_core.InputSignal<string | null>;
|
|
793
|
+
readonly send: _angular_core.OutputEmitterRef<string>;
|
|
794
|
+
readonly cancel: _angular_core.OutputEmitterRef<void>;
|
|
795
|
+
readonly restored: _angular_core.OutputEmitterRef<void>;
|
|
796
|
+
readonly inputId: string;
|
|
797
|
+
readonly hintId: string;
|
|
798
|
+
readonly text: _angular_core.WritableSignal<string>;
|
|
799
|
+
readonly length: _angular_core.Signal<number>;
|
|
800
|
+
readonly tooLong: _angular_core.Signal<boolean>;
|
|
801
|
+
readonly showCounter: _angular_core.Signal<boolean>;
|
|
802
|
+
readonly canSend: _angular_core.Signal<boolean>;
|
|
803
|
+
constructor();
|
|
804
|
+
onInput(event: Event): void;
|
|
805
|
+
onKeydown(event: KeyboardEvent): void;
|
|
806
|
+
submit(): void;
|
|
807
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantComposerComponent, never>;
|
|
808
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantComposerComponent, "nh-assistant-composer", never, { "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "busy": { "alias": "busy"; "required": false; "isSignal": true; }; "maxLength": { "alias": "maxLength"; "required": false; "isSignal": true; }; "restore": { "alias": "restore"; "required": false; "isSignal": true; }; }, { "send": "send"; "cancel": "cancel"; "restored": "restored"; }, never, never, true, never>;
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/** Shows one tool invocation with its status and expandable input and result previews. */
|
|
812
|
+
declare class NhAssistantToolCallCardComponent {
|
|
813
|
+
readonly part: _angular_core.InputSignal<ToolCallPart>;
|
|
814
|
+
readonly detailsId: string;
|
|
815
|
+
readonly expanded: _angular_core.WritableSignal<boolean>;
|
|
816
|
+
readonly statusIcon: _angular_core.Signal<NhAssistantIconName>;
|
|
817
|
+
readonly hasDetails: _angular_core.Signal<boolean>;
|
|
818
|
+
toggle(): void;
|
|
819
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantToolCallCardComponent, never>;
|
|
820
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantToolCallCardComponent, "nh-assistant-tool-call-card", never, { "part": { "alias": "part"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/** Formats remaining milliseconds as `m:ss`, or `h:mm:ss` above one hour. */
|
|
824
|
+
declare function formatNhAssistantCountdown(milliseconds: number): string;
|
|
825
|
+
/**
|
|
826
|
+
* Asks the user to approve or reject a proposed mutation. Shows the summary, targets,
|
|
827
|
+
* proposed arguments and a countdown to expiry. A decision is emitted at most once until
|
|
828
|
+
* the host reports that it is no longer deciding.
|
|
829
|
+
*/
|
|
830
|
+
declare class NhAssistantApprovalCardComponent {
|
|
831
|
+
readonly approval: _angular_core.InputSignal<ApprovalPart>;
|
|
832
|
+
/** True while the host submits a decision; disables both buttons. */
|
|
833
|
+
readonly deciding: _angular_core.InputSignal<boolean>;
|
|
834
|
+
readonly decide: _angular_core.OutputEmitterRef<ApprovalDecision>;
|
|
835
|
+
private readonly now;
|
|
836
|
+
private readonly submitted;
|
|
837
|
+
readonly remainingMs: _angular_core.Signal<number>;
|
|
838
|
+
readonly expired: _angular_core.Signal<boolean>;
|
|
839
|
+
readonly effectiveStatus: _angular_core.Signal<ApprovalStatus>;
|
|
840
|
+
readonly actionable: _angular_core.Signal<boolean>;
|
|
841
|
+
readonly disabled: _angular_core.Signal<boolean>;
|
|
842
|
+
readonly countdown: _angular_core.Signal<string>;
|
|
843
|
+
constructor();
|
|
844
|
+
choose(decision: ApprovalDecision): void;
|
|
845
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantApprovalCardComponent, never>;
|
|
846
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantApprovalCardComponent, "nh-assistant-approval-card", never, { "approval": { "alias": "approval"; "required": true; "isSignal": true; }; "deciding": { "alias": "deciding"; "required": false; "isSignal": true; }; }, { "decide": "decide"; }, never, never, true, never>;
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* Chooses the agent for new conversations. Agent names come from the host's translation
|
|
851
|
+
* keys; agents created by an administrator carry literal text, which is shown as is.
|
|
852
|
+
*/
|
|
853
|
+
declare class NhAssistantAgentPickerComponent {
|
|
854
|
+
readonly agents: _angular_core.InputSignal<readonly AgentSummary[]>;
|
|
855
|
+
readonly selectedAgentId: _angular_core.InputSignal<string | null>;
|
|
856
|
+
readonly disabled: _angular_core.InputSignal<boolean>;
|
|
857
|
+
readonly agentChange: _angular_core.OutputEmitterRef<string>;
|
|
858
|
+
readonly selectId: string;
|
|
859
|
+
readonly selected: _angular_core.Signal<AgentSummary | null>;
|
|
860
|
+
onChange(event: Event): void;
|
|
861
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantAgentPickerComponent, never>;
|
|
862
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantAgentPickerComponent, "nh-assistant-agent-picker", never, { "agents": { "alias": "agents"; "required": true; "isSignal": true; }; "selectedAgentId": { "alias": "selectedAgentId"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; }, { "agentChange": "agentChange"; }, never, never, true, never>;
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
/** Maximum length of the user's own instructions. */
|
|
866
|
+
declare const NH_ASSISTANT_MAX_CUSTOM_INSTRUCTIONS = 1000;
|
|
867
|
+
/**
|
|
868
|
+
* The user's own assistant preferences: style, form of address, answer length and
|
|
869
|
+
* optional instructions. Preferences steer style only; the server keeps them below the
|
|
870
|
+
* application context and agent instructions.
|
|
871
|
+
*/
|
|
872
|
+
declare class NhAssistantPreferencesComponent {
|
|
873
|
+
private readonly api;
|
|
874
|
+
private subscription?;
|
|
875
|
+
/** Emitted when the user leaves the preferences. */
|
|
876
|
+
readonly closed: _angular_core.OutputEmitterRef<void>;
|
|
877
|
+
/** Emitted with the stored preferences after a successful save. */
|
|
878
|
+
readonly saved: _angular_core.OutputEmitterRef<AssistantPreferences>;
|
|
879
|
+
readonly id: string;
|
|
880
|
+
readonly styles: readonly AssistantStyle[];
|
|
881
|
+
readonly addressForms: readonly AssistantAddressForm[];
|
|
882
|
+
readonly responseLengths: readonly AssistantResponseLength[];
|
|
883
|
+
readonly maxInstructions = 1000;
|
|
884
|
+
readonly loading: _angular_core.WritableSignal<boolean>;
|
|
885
|
+
readonly loadFailed: _angular_core.WritableSignal<boolean>;
|
|
886
|
+
readonly saving: _angular_core.WritableSignal<boolean>;
|
|
887
|
+
readonly savedMessage: _angular_core.WritableSignal<boolean>;
|
|
888
|
+
readonly error: _angular_core.WritableSignal<NhAssistantError | null>;
|
|
889
|
+
readonly style: _angular_core.WritableSignal<AssistantStyle>;
|
|
890
|
+
readonly addressForm: _angular_core.WritableSignal<AssistantAddressForm>;
|
|
891
|
+
readonly responseLength: _angular_core.WritableSignal<AssistantResponseLength>;
|
|
892
|
+
readonly customInstructions: _angular_core.WritableSignal<string>;
|
|
893
|
+
private readonly stored;
|
|
894
|
+
readonly instructionsLength: _angular_core.Signal<number>;
|
|
895
|
+
readonly tooLong: _angular_core.Signal<boolean>;
|
|
896
|
+
readonly dirty: _angular_core.Signal<boolean>;
|
|
897
|
+
readonly canSave: _angular_core.Signal<boolean>;
|
|
898
|
+
readonly errorKeys: _angular_core.Signal<string[]>;
|
|
899
|
+
constructor();
|
|
900
|
+
load(): void;
|
|
901
|
+
onInstructionsInput(event: Event): void;
|
|
902
|
+
choose<T>(target: {
|
|
903
|
+
set(value: T): void;
|
|
904
|
+
}, value: T): void;
|
|
905
|
+
save(): void;
|
|
906
|
+
private apply;
|
|
907
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantPreferencesComponent, never>;
|
|
908
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantPreferencesComponent, "nh-assistant-preferences", never, {}, { "closed": "closed"; "saved": "saved"; }, never, never, true, never>;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* Translates the first key that has a translation and otherwise returns the fallback text.
|
|
913
|
+
* Used for server-provided keys (agent names, error message keys, result codes) that the
|
|
914
|
+
* host may or may not translate.
|
|
915
|
+
*/
|
|
916
|
+
declare class NhAssistantTranslatePipe implements PipeTransform {
|
|
917
|
+
private readonly translate;
|
|
918
|
+
private lastKeys;
|
|
919
|
+
private lastParams;
|
|
920
|
+
private lastValue;
|
|
921
|
+
private dirty;
|
|
922
|
+
constructor();
|
|
923
|
+
transform(keys: string | readonly (string | null | undefined)[], fallback?: string, params?: Record<string, unknown>): string;
|
|
924
|
+
private resolve;
|
|
925
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantTranslatePipe, never>;
|
|
926
|
+
static ɵpipe: _angular_core.ɵɵPipeDeclaration<NhAssistantTranslatePipe, "nhAssistantTranslate", true>;
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
/** Converts any failure into a user-facing code and translation key, never raw text. */
|
|
930
|
+
declare function toNhAssistantError(error: unknown): NhAssistantError;
|
|
931
|
+
/** Translation keys for an error, from the most to the least specific. */
|
|
932
|
+
declare function nhAssistantErrorKeys(error: NhAssistantError | null): string[];
|
|
933
|
+
/** Dash-case identifiers as the contract requires for agent and MCP server ids. */
|
|
934
|
+
declare const NH_ASSISTANT_DASH_CASE: RegExp;
|
|
935
|
+
|
|
936
|
+
export { NH_ASSISTANT_ACCESS_POLICY, NH_ASSISTANT_CONFIG, NH_ASSISTANT_FETCH, NH_ASSISTANT_ICONS, NH_ASSISTANT_MAX_CUSTOM_INSTRUCTIONS, NH_ASSISTANT_PAGE_CONTEXT_LIMITS, NH_ASSISTANT_PANEL_MOBILE_QUERY, NH_ASSISTANT_PANEL_WIDTH, NH_ASSISTANT_SSE_EVENT_TYPES, NH_ASSISTANT_TRANSLATIONS, NH_ASSISTANT_VIRTUAL_SCROLL_THRESHOLD, NhAssistantAdminApiService, NhAssistantAgentPickerComponent, NhAssistantAllowAllAccessPolicy, NhAssistantApiError, NhAssistantApiService, NhAssistantApprovalCardComponent, NhAssistantClientErrorCodes, NhAssistantComposerComponent, NhAssistantConversationListComponent, NhAssistantLauncherComponent, NhAssistantPanelComponent, NhAssistantPanelService, NhAssistantPreferencesComponent, NhAssistantSseParser, NhAssistantStore, NhAssistantThreadComponent, NhAssistantToolCallCardComponent, NhAssistantTranslationMerger, applyNhAssistantApprovalDecision, applyNhAssistantEvent, describeNhAssistantClientContext, formatNhAssistantCountdown, nhAssistantCodeForStatus, nhAssistantErrorMessageKey, normalizeNhAssistantClientContext, provideNhAssistant, NH_ASSISTANT_DASH_CASE as ɵNH_ASSISTANT_DASH_CASE, NhAssistantIconComponent as ɵNhAssistantIconComponent, NhAssistantTranslatePipe as ɵNhAssistantTranslatePipe, nhAssistantErrorKeys as ɵnhAssistantErrorKeys, toNhAssistantError as ɵtoNhAssistantError };
|
|
937
|
+
export type { AdminAgent, AdminAgentInput, AgentSummary, ApplicationContext, ApplicationContextVersion, ApprovalDecision, ApprovalPart, ApprovalRequiredEvent, ApprovalStatus, AssistantAddressForm, AssistantAutonomy, AssistantErrorEvent, AssistantPreferences, AssistantResponseLength, AssistantStatus, AssistantStyle, ClientContext, ClientContextEntity, Conversation, ConversationPage, ConversationStatus, ConversationSummary, CreateConversationRequest, DecideApprovalRequest, McpAuthMode, McpServer, McpServerInput, McpServerTestResult, McpTool, McpToolEffect, McpToolStatus, Message, MessageDeltaEvent, MessagePart, NhAssistantAccessPolicy, NhAssistantClientContext, NhAssistantClientErrorCode, NhAssistantConfig, NhAssistantError, NhAssistantFetch, NhAssistantIconName, NhAssistantRawSseMessage, NhAssistantSseEvent, NhAssistantSseEventMap, NhAssistantSseEventType, NhAssistantStatusCodes, SendMessageRequest, TextPart, ToolCallPart, ToolCallStatus, ToolCatalogEffect, ToolCatalogEntry, ToolCompletedEvent, ToolStartedEvent, TurnCompletedEvent, TurnCompletionStatus, TurnStartedEvent, TurnUsage, UpdateAdminAgentRequest, UpdateApplicationContextRequest, UpdateMcpToolRequest };
|