@newheap/platform-ai-chat 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/admin/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { NhAssistantStore, NhAssistantError, ApplicationContext, ApplicationContextVersion, AdminAgent, ToolCatalogEntry, McpServer, AssistantAutonomy, AgentProposalFeedbackCategory, AgentFeedbackSummaryRow, AgentFeedbackItem, AgentFeedbackCategoryCount, AgentProposalFeedbackGroup, McpServerTestResult, McpAuthMode, McpToolEffect, McpTool } from '@newheap/platform-ai-chat';
2
+ import { NhAssistantStore, NhAssistantError, ApplicationContext, ApplicationContextVersion, AdminAgent, ToolCatalogEntry, McpServer, SetAgentStateRequest, AgentSkillState, AssistantAutonomy, AgentEvaluation, AgentReplay, AgentEvaluationCost, AgentProposalFeedbackCategory, AgentFeedbackSummaryRow, AgentFeedbackItem, AgentFeedbackCategoryCount, StaleKind, AgentProposalFeedbackGroup, McpServerTestResult, McpAuthMode, McpToolEffect, McpTool } from '@newheap/platform-ai-chat';
3
3
 
4
4
  type NhAssistantAdminTab = 'context' | 'agents' | 'mcp-servers';
5
5
  /**
@@ -59,10 +59,13 @@ declare class NhAssistantAdminContextComponent {
59
59
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantAdminContextComponent, "nh-assistant-admin-context", never, {}, {}, never, never, true, never>;
60
60
  }
61
61
 
62
+ type AgentStateAction = SetAgentStateRequest['state'];
62
63
  /**
63
- * Agent administration: code agents (override, disable, reset) and agents created here
64
- * (edit, disable, delete). Editing opens `nh-assistant-admin-agent-editor`; the feedback action
65
- * opens `nh-assistant-agent-feedback-report` for the agent.
64
+ * Agent administration: code agents (override, reset) and agents created here (edit, delete),
65
+ * and for every agent its run state with pause, stop and resume, each with an optional reason.
66
+ * Editing opens `nh-assistant-admin-agent-editor`; the feedback action opens
67
+ * `nh-assistant-agent-feedback-report` for the agent, and the evaluation action of an agent with
68
+ * shadow variants opens `nh-assistant-agent-evaluation`.
66
69
  */
67
70
  declare class NhAssistantAdminAgentsComponent {
68
71
  private readonly admin;
@@ -70,6 +73,7 @@ declare class NhAssistantAdminAgentsComponent {
70
73
  private readonly injector;
71
74
  private readonly host;
72
75
  private readonly backButton;
76
+ private readonly reasonInput;
73
77
  private subscription?;
74
78
  private actionSubscription?;
75
79
  readonly id: string;
@@ -82,11 +86,21 @@ declare class NhAssistantAdminAgentsComponent {
82
86
  readonly editing: _angular_core.WritableSignal<AdminAgent | null | undefined>;
83
87
  /** The agent whose feedback report is shown instead of the list. */
84
88
  readonly reporting: _angular_core.WritableSignal<AdminAgent | null>;
89
+ /** The agent whose comparison with its shadow variants is shown instead of the list. */
90
+ readonly evaluating: _angular_core.WritableSignal<AdminAgent | null>;
85
91
  readonly confirming: _angular_core.WritableSignal<{
86
92
  agentId: string;
87
93
  action: "delete" | "reset";
88
94
  } | null>;
89
95
  readonly busyAgentId: _angular_core.WritableSignal<string | null>;
96
+ /** The state change whose reason is being entered, of the agent or one of its skills. */
97
+ readonly changingState: _angular_core.WritableSignal<{
98
+ agentId: string;
99
+ skillId?: string;
100
+ state: AgentStateAction;
101
+ } | null>;
102
+ readonly stateReason: _angular_core.WritableSignal<string>;
103
+ readonly maxReason = 500;
90
104
  readonly error: _angular_core.WritableSignal<NhAssistantError | null>;
91
105
  readonly errorKeys: _angular_core.Signal<string[]>;
92
106
  constructor();
@@ -95,10 +109,24 @@ declare class NhAssistantAdminAgentsComponent {
95
109
  edit(agent: AdminAgent): void;
96
110
  /** Shows what people said when they rejected the agent's proposals. */
97
111
  openReport(agent: AdminAgent): void;
112
+ /** The shadow variants of an agent, by id. */
113
+ variantsOf(agent: AdminAgent): string[];
114
+ /** Compares the agent with its shadow variants. */
115
+ openEvaluation(agent: AdminAgent): void;
116
+ /** Returns to the list and to the evaluation action of the agent whose comparison was open. */
117
+ closeEvaluation(): void;
98
118
  /** Returns to the list and to the feedback action of the agent whose report was open. */
99
119
  closeReport(): void;
100
120
  onSaved(agent: AdminAgent): void;
101
- setEnabled(agent: AdminAgent, isEnabled: boolean): void;
121
+ /** The state changes the agent allows: none for an agent that is disabled in code. */
122
+ stateActions(agent: AdminAgent): AgentStateAction[];
123
+ /** The state changes a skill allows. */
124
+ skillActions(skill: AgentSkillState): AgentStateAction[];
125
+ /** Opens the reason form of a state change of the agent or, with a skill, of that skill. */
126
+ askState(agent: AdminAgent, state: AgentStateAction, skill?: AgentSkillState): void;
127
+ isChangingState(agentId: string, state: AgentStateAction, skillId?: string): boolean;
128
+ applyState(agent: AdminAgent): void;
129
+ value(event: Event): string;
102
130
  confirm(agentId: string, action: 'delete' | 'reset'): void;
103
131
  isConfirming(agentId: string, action: 'delete' | 'reset'): boolean;
104
132
  reset(agent: AdminAgent): void;
@@ -135,7 +163,6 @@ declare class NhAssistantAdminAgentEditorComponent {
135
163
  readonly instructions: _angular_core.WritableSignal<string>;
136
164
  readonly autonomy: _angular_core.WritableSignal<AssistantAutonomy>;
137
165
  readonly requiredPolicy: _angular_core.WritableSignal<string>;
138
- readonly isEnabled: _angular_core.WritableSignal<boolean>;
139
166
  readonly toolSelectors: _angular_core.WritableSignal<string[]>;
140
167
  readonly mcpServerIds: _angular_core.WritableSignal<string[]>;
141
168
  readonly newSelector: _angular_core.WritableSignal<string>;
@@ -168,11 +195,92 @@ declare class NhAssistantAdminAgentEditorComponent {
168
195
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantAdminAgentEditorComponent, "nh-assistant-admin-agent-editor", never, { "agent": { "alias": "agent"; "required": false; "isSignal": true; }; "tools": { "alias": "tools"; "required": false; "isSignal": true; }; "servers": { "alias": "servers"; "required": false; "isSignal": true; }; }, { "saved": "saved"; "cancelled": "cancelled"; }, never, never, true, never>;
169
196
  }
170
197
 
198
+ /** Periods the evaluation offers, in days before now; the server allows at most 92. */
199
+ type NhAssistantEvaluationPeriod = 7 | 30 | 90;
200
+ /** One row of the cost comparison: a measure of the live agent next to the variant's. */
201
+ interface NhAssistantCostRow {
202
+ key: 'runs' | 'model-calls' | 'tokens' | 'tool-calls';
203
+ live: AgentEvaluationCost;
204
+ variant: AgentEvaluationCost;
205
+ }
206
+ /**
207
+ * Compares a shadow variant of an agent with the live agent, for the agent's administrators: the
208
+ * runs that handled the same events, per tool the proposals both made, only one made and what
209
+ * people decided about the live ones, what each cost and how each routed, with links to the threads
210
+ * of the differences. Small numbers mislead, so counts stand next to every share. Administrators
211
+ * replay the recorded runs of the period into the variant and export the comparison as JSON Lines.
212
+ * The report holds no messages or arguments.
213
+ */
214
+ declare class NhAssistantAgentEvaluationComponent {
215
+ private readonly admin;
216
+ private readonly panel;
217
+ private readonly document;
218
+ private subscription?;
219
+ private replaySubscription?;
220
+ /** The live agent. */
221
+ readonly agentId: _angular_core.InputSignal<string>;
222
+ /** Its shadow variants; the first is compared until another is chosen. */
223
+ readonly variants: _angular_core.InputSignal<readonly string[]>;
224
+ readonly id: string;
225
+ readonly periods: readonly NhAssistantEvaluationPeriod[];
226
+ readonly maxReplayRuns = 500;
227
+ readonly canOpenThreads: boolean;
228
+ readonly variant: _angular_core.WritableSignal<string>;
229
+ readonly period: _angular_core.WritableSignal<NhAssistantEvaluationPeriod>;
230
+ readonly loading: _angular_core.WritableSignal<boolean>;
231
+ readonly error: _angular_core.WritableSignal<NhAssistantError | null>;
232
+ readonly errorKeys: _angular_core.Signal<string[]>;
233
+ readonly evaluation: _angular_core.WritableSignal<AgentEvaluation | null>;
234
+ readonly exporting: _angular_core.WritableSignal<boolean>;
235
+ readonly exportError: _angular_core.WritableSignal<NhAssistantError | null>;
236
+ readonly exportErrorKeys: _angular_core.Signal<string[]>;
237
+ readonly canExport: _angular_core.Signal<boolean>;
238
+ readonly replays: _angular_core.WritableSignal<AgentReplay[]>;
239
+ readonly replayRuns: _angular_core.WritableSignal<number>;
240
+ readonly replaying: _angular_core.WritableSignal<boolean>;
241
+ readonly replayError: _angular_core.WritableSignal<NhAssistantError | null>;
242
+ readonly replayErrorKeys: _angular_core.Signal<string[]>;
243
+ readonly replayRunning: _angular_core.Signal<boolean>;
244
+ readonly costRows: _angular_core.Signal<NhAssistantCostRow[]>;
245
+ /** Routing matters only when one of the two worked in a skill. */
246
+ readonly showRouting: _angular_core.Signal<boolean>;
247
+ /** The period the last load asked for, so the report, the export and a replay agree. */
248
+ private range;
249
+ constructor();
250
+ /** Reloads the comparison and the variant's replays for the chosen period. */
251
+ load(): void;
252
+ loadReplays(): void;
253
+ onVariant(event: Event): void;
254
+ onPeriod(event: Event): void;
255
+ onReplayRuns(event: Event): void;
256
+ /** Replays the live agent's recorded runs of the period into the variant. */
257
+ replay(): void;
258
+ /** Downloads the paired runs of the comparison as a JSON Lines file. */
259
+ export(): Promise<void>;
260
+ /** Opens a thread of the comparison in the assistant panel, when the host has one. */
261
+ openThread(conversationId: string): void;
262
+ /** The share of a count in a total, or `null` without a total. */
263
+ share(count: number, total: number): number | null;
264
+ total(row: AgentEvaluation['tools'][number]): number;
265
+ categories(row: AgentEvaluation['tools'][number]): {
266
+ category: string;
267
+ count: number;
268
+ }[];
269
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantAgentEvaluationComponent, never>;
270
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantAgentEvaluationComponent, "nh-assistant-agent-evaluation", never, { "agentId": { "alias": "agentId"; "required": true; "isSignal": true; }; "variants": { "alias": "variants"; "required": true; "isSignal": true; }; }, {}, never, never, true, never>;
271
+ }
272
+
171
273
  /** Periods the report offers, in days before now. */
172
274
  type NhAssistantFeedbackPeriod = 7 | 30 | 90;
173
- /** A summary row with its most frequent feedback categories. */
275
+ /** A summary row with its most frequent feedback categories and why open proposals closed. */
174
276
  interface NhAssistantFeedbackSummaryView extends AgentFeedbackSummaryRow {
175
277
  topCategories: AgentFeedbackCategoryCount[];
278
+ /** Open proposals closed before a decision, per kind, most frequent first. */
279
+ invalidatedKinds: {
280
+ kind: StaleKind;
281
+ count: number;
282
+ reasons: string;
283
+ }[];
176
284
  }
177
285
  /**
178
286
  * What people said when they rejected an agent's proposals, for the agent's administrators: per
@@ -365,5 +473,5 @@ declare class NhAssistantAdminMcpToolsComponent {
365
473
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantAdminMcpToolsComponent, "nh-assistant-admin-mcp-tools", never, { "server": { "alias": "server"; "required": true; "isSignal": true; }; }, { "closed": "closed"; "synced": "synced"; }, never, never, true, never>;
366
474
  }
367
475
 
368
- export { NH_ASSISTANT_MAX_INSTRUCTIONS, NhAssistantAdminAgentEditorComponent, NhAssistantAdminAgentsComponent, NhAssistantAdminComponent, NhAssistantAdminContextComponent, NhAssistantAdminMcpServerEditorComponent, NhAssistantAdminMcpServersComponent, NhAssistantAdminMcpToolsComponent, NhAssistantAgentFeedbackReportComponent, nhAssistantSelectorMatches };
369
- export type { NhAssistantAdminTab, NhAssistantFeedbackPeriod, NhAssistantSecretAction };
476
+ export { NH_ASSISTANT_MAX_INSTRUCTIONS, NhAssistantAdminAgentEditorComponent, NhAssistantAdminAgentsComponent, NhAssistantAdminComponent, NhAssistantAdminContextComponent, NhAssistantAdminMcpServerEditorComponent, NhAssistantAdminMcpServersComponent, NhAssistantAdminMcpToolsComponent, NhAssistantAgentEvaluationComponent, NhAssistantAgentFeedbackReportComponent, nhAssistantSelectorMatches };
477
+ export type { NhAssistantAdminTab, NhAssistantEvaluationPeriod, NhAssistantFeedbackPeriod, NhAssistantSecretAction };
@@ -8,7 +8,9 @@ import { AgentProposal, AgentThreadLookup, AgentTriggerReceipt, NhAssistantError
8
8
  * server checks each decision against the proposal's approval policy again. After a rejection the
9
9
  * inbox asks, optionally, what was wrong, also when the rejected proposals have left the list.
10
10
  * With live updates the inbox reloads by itself when agent work changes, for example when a
11
- * colleague decided a proposal or a run proposed a new one.
11
+ * colleague decided a proposal or a run proposed a new one. A proposal that closes because it no
12
+ * longer fits, for example because someone did the work by hand, stays as a closed card with the
13
+ * reason until it is dismissed.
12
14
  */
13
15
  declare class NhAssistantAgentInboxComponent {
14
16
  private readonly api;
@@ -114,6 +116,11 @@ interface NhAssistantFeedbackRequest {
114
116
  * optionally and above the list, what was wrong; closed proposals keep a low-key action to give or
115
117
  * change that feedback later. With `decisionRights` each proposal has its own right, for example
116
118
  * from the agent work on a subject, and a pending proposal the viewer may not decide says who does.
119
+ * A proposal that no longer fits, for example because a person already did the work, shows why.
120
+ * With `holdClosedCards`, a list of open proposals keeps such a proposal, or one a newer proposal
121
+ * replaced, as a closed card when it closes while shown, or when an approval is refused because of
122
+ * it, until the person dismisses it. It reads those proposals by id with one lookup, never through
123
+ * their threads.
117
124
  */
118
125
  declare class NhAssistantAgentProposalsComponent {
119
126
  private readonly api;
@@ -129,6 +136,12 @@ declare class NhAssistantAgentProposalsComponent {
129
136
  */
130
137
  readonly decisionRights: _angular_core.InputSignal<ReadonlyMap<string, AgentProposalDecisionRight> | null>;
131
138
  readonly selectable: _angular_core.InputSignal<boolean>;
139
+ /**
140
+ * Keeps proposals that close as stale or are replaced while shown as closed cards with their
141
+ * explanation until they are dismissed. For lists of open proposals, which drop a proposal once
142
+ * it closes.
143
+ */
144
+ readonly holdClosedCards: _angular_core.InputSignal<boolean>;
132
145
  /** Emits after a proposal or its feedback changed, so the host reloads its list. */
133
146
  readonly changed: _angular_core.OutputEmitterRef<void>;
134
147
  readonly busy: _angular_core.WritableSignal<boolean>;
@@ -140,7 +153,30 @@ declare class NhAssistantAgentProposalsComponent {
140
153
  readonly allSelected: _angular_core.Signal<boolean>;
141
154
  /** The feedback question. It does not depend on `proposals`, which drop rejected proposals in the inbox. */
142
155
  readonly feedback: _angular_core.WritableSignal<NhAssistantFeedbackRequest | null>;
156
+ /** Proposals that closed as stale while shown, kept until dismissed; newest first. */
157
+ readonly held: _angular_core.WritableSignal<AgentProposal[]>;
158
+ /** The held closed cards first, then the proposals the host gave. */
159
+ readonly shown: _angular_core.Signal<AgentProposal[]>;
160
+ private readonly lookups;
143
161
  constructor();
162
+ /**
163
+ * The translation key of a proposal's status: the kind of a stale proposal, "replaced" for a
164
+ * superseded one, otherwise its status.
165
+ */
166
+ statusKey(proposal: AgentProposal): string;
167
+ /** True when the newer proposal that replaced this one is in the list. */
168
+ hasSuccessor(proposal: AgentProposal): boolean;
169
+ /** Moves focus to the newer proposal that replaced this one. */
170
+ showSuccessor(proposal: AgentProposal): void;
171
+ /** True for a closed card the list keeps until it is dismissed. */
172
+ isHeld(proposal: AgentProposal): boolean;
173
+ /** Removes a closed card. */
174
+ dismiss(proposal: AgentProposal): void;
175
+ /**
176
+ * Called by a host of open proposals after a live update replaced `previous` with `next`: keeps
177
+ * the shown pending proposals that left the list because they closed as stale or were replaced.
178
+ */
179
+ holdClosed(previous: readonly AgentProposal[], next: readonly AgentProposal[]): void;
144
180
  /** Whether the caller may decide this proposal: its own right when one was given, otherwise `canDecide`. */
145
181
  mayDecide(proposal: AgentProposal): boolean;
146
182
  /**
@@ -164,16 +200,21 @@ declare class NhAssistantAgentProposalsComponent {
164
200
  /** Closes the question; from a card, focus returns to the card's feedback action. */
165
201
  onFeedbackDismissed(): void;
166
202
  private ask;
203
+ /**
204
+ * Reads `proposals` again by id and keeps those that closed as stale or were replaced as closed
205
+ * cards, with their kind and explanation or their successor.
206
+ */
207
+ private holdStale;
167
208
  private run;
168
209
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantAgentProposalsComponent, never>;
169
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantAgentProposalsComponent, "nh-assistant-agent-proposals", never, { "proposals": { "alias": "proposals"; "required": true; "isSignal": true; }; "canDecide": { "alias": "canDecide"; "required": false; "isSignal": true; }; "decisionRights": { "alias": "decisionRights"; "required": false; "isSignal": true; }; "selectable": { "alias": "selectable"; "required": false; "isSignal": true; }; }, { "changed": "changed"; }, never, never, true, never>;
210
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantAgentProposalsComponent, "nh-assistant-agent-proposals", never, { "proposals": { "alias": "proposals"; "required": true; "isSignal": true; }; "canDecide": { "alias": "canDecide"; "required": false; "isSignal": true; }; "decisionRights": { "alias": "decisionRights"; "required": false; "isSignal": true; }; "selectable": { "alias": "selectable"; "required": false; "isSignal": true; }; "holdClosedCards": { "alias": "holdClosedCards"; "required": false; "isSignal": true; }; }, { "changed": "changed"; }, never, never, true, never>;
170
211
  }
171
212
 
172
213
  /**
173
214
  * The runs of an agent thread, newest first: trigger, status, failure, usage, proposals and the
174
- * summary the next run starts from. Participants cancel an open run; approvers resume or restart
175
- * a failed or cancelled one. With live updates it reloads by itself when a run or proposal of the
176
- * thread changes.
215
+ * summary the next run starts from, and the agent that handed a run its work. Participants cancel
216
+ * an open run; approvers resume or restart a failed or cancelled one. With live updates it reloads
217
+ * by itself when a run or proposal of the thread changes.
177
218
  */
178
219
  declare class NhAssistantRunTimelineComponent {
179
220
  private readonly api;
@@ -183,6 +224,8 @@ declare class NhAssistantRunTimelineComponent {
183
224
  readonly role: _angular_core.InputSignal<AgentSubjectRole>;
184
225
  /** Emits after a run was cancelled or retried. */
185
226
  readonly changed: _angular_core.OutputEmitterRef<void>;
227
+ /** Emits the thread of the agent that handed a run its work, so the host can open it. */
228
+ readonly openConversation: _angular_core.OutputEmitterRef<string>;
186
229
  readonly loading: _angular_core.WritableSignal<boolean>;
187
230
  readonly loadFailed: _angular_core.WritableSignal<boolean>;
188
231
  readonly runs: _angular_core.WritableSignal<AgentRun[]>;
@@ -201,7 +244,7 @@ declare class NhAssistantRunTimelineComponent {
201
244
  /** A quiet load, after a live update, shows no loading state and keeps the runs when it fails. */
202
245
  private fetch;
203
246
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<NhAssistantRunTimelineComponent, never>;
204
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantRunTimelineComponent, "nh-assistant-run-timeline", never, { "conversationId": { "alias": "conversationId"; "required": true; "isSignal": true; }; "role": { "alias": "role"; "required": false; "isSignal": true; }; }, { "changed": "changed"; }, never, never, true, never>;
247
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<NhAssistantRunTimelineComponent, "nh-assistant-run-timeline", never, { "conversationId": { "alias": "conversationId"; "required": true; "isSignal": true; }; "role": { "alias": "role"; "required": false; "isSignal": true; }; }, { "changed": "changed"; "openConversation": "openConversation"; }, never, never, true, never>;
205
248
  }
206
249
 
207
250
  /**
@@ -282,8 +325,9 @@ interface NhAssistantStartedAgent {
282
325
  * decides when the viewer may not and the optional question after a rejection, and per agent the
283
326
  * conversation about the subject and, for participants, a start action. `agentId` names the agent
284
327
  * whose conversation the host offers also before it worked on the subject. With live updates the
285
- * view reloads by itself when agent work on its subject changes. Opening a conversation uses
286
- * `NhAssistantPanelService.openSubject` and emits `conversationOpened` afterwards.
328
+ * view reloads by itself when agent work on its subject changes; a proposal that closes because it
329
+ * no longer fits stays as a closed card with the reason until it is dismissed. Opening a
330
+ * conversation uses `NhAssistantPanelService.openSubject` and emits `conversationOpened` afterwards.
287
331
  */
288
332
  declare class NhAssistantSubjectSuggestionsComponent {
289
333
  private readonly api;