@newheap/platform-ai-chat 0.18.0 → 0.19.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@newheap/platform-ai-chat",
3
- "version": "0.18.0",
3
+ "version": "0.19.0",
4
4
  "peerDependencies": {
5
5
  "@angular/cdk": "^20.2.14",
6
6
  "@angular/common": "^20.3.28",
@@ -8,7 +8,9 @@
8
8
  * It shows a notification only when no window of the application is focused; otherwise it
9
9
  * forwards the message to the open windows, which already show the conversation live. A click
10
10
  * focuses an open window and opens the conversation there, or opens `app` with the conversation
11
- * in the URL fragment. Notifications carry a conversation id and short texts only.
11
+ * in the URL fragment. A notification about the proposals of a run also carries the run, which the
12
+ * click forwards, so the application can open its inbox of the run (`openRun$`). Notifications
13
+ * carry a conversation id, a run id and short texts only.
12
14
  */
13
15
  const settings = new URL(self.location.href).searchParams;
14
16
  const appUrl = settings.get('app') || '/';
@@ -27,12 +29,13 @@ self.addEventListener('push', event => {
27
29
  if (!payload || payload.type !== 'nh-assistant' || typeof payload.conversationId !== 'string') {
28
30
  return;
29
31
  }
32
+ const runId = typeof payload.runId === 'string' ? payload.runId : undefined;
30
33
 
31
34
  event.waitUntil((async () => {
32
35
  const windows = await self.clients.matchAll({ type: 'window', includeUncontrolled: true });
33
36
  if (windows.some(client => client.focused && client.visibilityState === 'visible')) {
34
37
  for (const client of windows) {
35
- client.postMessage({ type: 'nh-assistant.push', kind: payload.kind, conversationId: payload.conversationId });
38
+ client.postMessage({ type: 'nh-assistant.push', kind: payload.kind, conversationId: payload.conversationId, runId });
36
39
  }
37
40
  return;
38
41
  }
@@ -42,29 +45,33 @@ self.addEventListener('push', event => {
42
45
  tag: String(payload.tag || `nh-assistant:${payload.conversationId}`),
43
46
  renotify: true,
44
47
  icon: iconUrl,
45
- data: { conversationId: payload.conversationId }
48
+ data: { conversationId: payload.conversationId, runId }
46
49
  });
47
50
  })());
48
51
  });
49
52
 
50
53
  self.addEventListener('notificationclick', event => {
51
54
  event.notification.close();
52
- const conversationId = event.notification.data && event.notification.data.conversationId;
55
+ const data = event.notification.data || {};
56
+ const conversationId = data.conversationId;
53
57
  if (typeof conversationId !== 'string') {
54
58
  return;
55
59
  }
60
+ const runId = typeof data.runId === 'string' ? data.runId : undefined;
56
61
 
57
62
  event.waitUntil((async () => {
58
63
  const windows = await self.clients.matchAll({ type: 'window', includeUncontrolled: true });
59
64
  const target = windows.find(client => client.focused) || windows[0];
60
65
  if (target) {
61
66
  await target.focus();
62
- target.postMessage({ type: 'nh-assistant.open-conversation', conversationId });
67
+ target.postMessage({ type: 'nh-assistant.open-conversation', conversationId, runId });
63
68
  return;
64
69
  }
65
70
 
66
71
  const url = new URL(appUrl, self.location.origin);
67
- url.hash = `nh-assistant-conversation=${encodeURIComponent(conversationId)}`;
72
+ url.hash = runId
73
+ ? `nh-assistant-run=${encodeURIComponent(runId)}.${encodeURIComponent(conversationId)}`
74
+ : `nh-assistant-conversation=${encodeURIComponent(conversationId)}`;
68
75
  await self.clients.openWindow(url.href);
69
76
  })());
70
77
  });
@@ -1,4 +1,4 @@
1
- import { AssistantStatus, AgentSummary, Conversation, ClientContext, NhAssistantConsultationLeaveRoute, AssistantPreferences, ToolCatalogEntry, AdminAgentInput, NhAssistantConsultationRoute, DataConsultationRequest, CodeRunSettings, AgentRunSettingsRequest, DataSkillRequest, DataTriggerRequest, McpServerInput, McpCustomAuthMode, McpDiscovery, RunCatalog, AssistantDataClassification, AssistantAccount, AgentRunStatus, AgentTriggerReceipt, AgentRunMcpSkip, ApprovalPresentation, AgentProposalStatus, AgentProposalOrigin, AgentProposalParent, AgentGrantSource, AgentConsultationStatus, NhAssistantMcpAuthorizationWindow, NhAssistantMcpAuthorizationOutcome, NhAssistantMcpAuthorizationHandle, LiveConversationChanged, LiveConversationRead, LiveConversationRemoved, LiveConversationEvent, LiveAgentWorkChanged, ApplicationMessageDetails, Message, FileReference, NhAssistantUploadRequest, NhAssistantLiveService, NhAssistantLiveState } from '@newheap/platform-ai-chat';
1
+ import { AssistantStatus, AgentSummary, Conversation, ClientContext, NhAssistantConsultationLeaveRoute, AssistantPreferences, ToolCatalogEntry, AdminAgentInput, NhAssistantConsultationRoute, DataConsultationRequest, CodeRunSettings, AgentRunSettingsRequest, DataSkillRequest, DataTriggerRequest, McpServerInput, McpCustomAuthMode, McpDiscovery, RunCatalog, AssistantDataClassification, AssistantAccount, AgentPackage, AgentRunStatus, AgentTriggerReceipt, AgentRunMcpSkip, ApprovalPresentation, AgentProposalStatus, AgentProposalOrigin, AgentProposalParent, AgentGrantSource, AgentConsultationStatus, NhAssistantMcpAuthorizationWindow, NhAssistantMcpAuthorizationOutcome, NhAssistantMcpAuthorizationHandle, LiveConversationChanged, LiveConversationRead, LiveConversationRemoved, LiveConversationEvent, LiveAgentWorkChanged, ApplicationMessageDetails, Message, FileReference, NhAssistantUploadRequest, NhAssistantLiveService, NhAssistantLiveState } from '@newheap/platform-ai-chat';
2
2
  import * as _angular_core from '@angular/core';
3
3
  import { InjectionToken, EnvironmentProviders } from '@angular/core';
4
4
  import { Observable } from 'rxjs';
@@ -136,6 +136,31 @@ interface NhAssistantMockMcpServer extends McpServerInput {
136
136
  /** A server each person connects to starts with the caller's own account connected. */
137
137
  personalConnected?: boolean;
138
138
  }
139
+ /**
140
+ * An entry of agent metadata as the application registers it with `AddAgentMetadata`: its name,
141
+ * whether administrators may override it on agents in code, its size limit, its searchable value and
142
+ * its checks.
143
+ */
144
+ interface NhAssistantMockAgentMetadataEntry {
145
+ /** The entry's dash-case name. */
146
+ name: string;
147
+ /** Administrators may override it on agents in code, as `Editable()`. */
148
+ editable?: boolean;
149
+ /** The largest value in bytes of its JSON; 4,096 by default. */
150
+ maxBytes?: number;
151
+ /** The field of the value whose text is its searchable value, as `IndexBy`. */
152
+ indexBy?: string;
153
+ /**
154
+ * The fields of the entry's type: a value with another field is refused with `value: invalid`, as
155
+ * the server refuses JSON that does not fit the type. Without it every field is accepted.
156
+ */
157
+ fields?: string[];
158
+ /**
159
+ * Checks a value as the application's validators do: codes by field path, `''` for the whole value,
160
+ * such as `{ code: ['unknown-code'] }`; `null` or an empty record accepts it.
161
+ */
162
+ validate?: (value: Record<string, unknown>) => Record<string, string[]> | null;
163
+ }
139
164
  /**
140
165
  * A preconfigured agent. Code agents default to the scenario's chat agents. `startsOff` starts it
141
166
  * off, as `StartsOff()` in code does for an agent in code.
@@ -152,8 +177,11 @@ interface NhAssistantMockAdminAgent extends AdminAgentInput {
152
177
  shadow?: boolean;
153
178
  startsOff?: boolean;
154
179
  }[];
155
- /** The live agent this code agent is a shadow variant of. */
156
- shadowOf?: string;
180
+ /**
181
+ * The live agent this code agent is a shadow variant of, as `ShadowOf` in code. A data variant is
182
+ * created with `POST admin/agents` and `shadowOf` instead.
183
+ */
184
+ shadowOf?: string | null;
157
185
  /** The agent starts in shadow, as with `Shadow()` in code. */
158
186
  shadow?: boolean;
159
187
  /** The technical account in code, as with `ServiceAccount(actorId)`. */
@@ -171,6 +199,11 @@ interface NhAssistantMockAdminAgent extends AdminAgentInput {
171
199
  * code that only answers.
172
200
  */
173
201
  consultationDescriptions?: Record<string, string>;
202
+ /**
203
+ * The tool selections of a code agent's consultations in code, by subject type, as `Tools` in
204
+ * `AllowConsultation`; a type without one offers every tool of the agent.
205
+ */
206
+ consultationTools?: Record<string, string[]>;
174
207
  /**
175
208
  * The ceiling of a code agent that administrators may make consultable as data, as
176
209
  * `ConsultableAsData` in code; it applies together with the scenario's `consultationsAsData`. `{}`
@@ -203,6 +236,47 @@ interface NhAssistantMockAdminAgent extends AdminAgentInput {
203
236
  * the administration offers the guided setup.
204
237
  */
205
238
  runConfiguration?: NhAssistantMockRunConfigurationPreset;
239
+ /**
240
+ * The hand-offs a code agent accepts in code, as `AcceptHandOffs`; they cannot change in the
241
+ * administration, and a hand-off as data about the same type is refused.
242
+ */
243
+ codeHandOffs?: NhAssistantMockCodeHandOff[];
244
+ }
245
+ /** A hand-off a code agent of the scenario accepts in code. */
246
+ interface NhAssistantMockCodeHandOff {
247
+ subjectType: string;
248
+ sources: string[];
249
+ description?: string;
250
+ notifySource?: boolean;
251
+ /** 5 by default, as in code. */
252
+ maxPerSubjectPerDay?: number;
253
+ }
254
+ /**
255
+ * The ceiling in code of hand-offs defined as data, as `UseHandOffsAsData`: per subject type the
256
+ * agents that may accept them as data and the agents that may hand off, and the highest daily limit
257
+ * (100 by default).
258
+ */
259
+ interface NhAssistantMockHandOffCeiling {
260
+ rules: NhAssistantMockHandOffRule[];
261
+ maxPerSubjectPerDay?: number;
262
+ }
263
+ /** One connection of the ceiling, as `Allow(subjectType, rule => rule.To(...).From(...))`. */
264
+ interface NhAssistantMockHandOffRule {
265
+ subjectType: string;
266
+ to?: string[];
267
+ toAgentsCreatedInAdministration?: boolean;
268
+ from?: string[];
269
+ fromAgentsCreatedInAdministration?: boolean;
270
+ }
271
+ /**
272
+ * The ceiling in code of shadow variants created as data, as `UseShadowVariantsAsData`: the live agents
273
+ * in code that may get them, whether agents created in the administration may too, and how many each
274
+ * (3 by default).
275
+ */
276
+ interface NhAssistantMockShadowVariantCeiling {
277
+ of?: string[];
278
+ ofAgentsCreatedInAdministration?: boolean;
279
+ maxPerAgent?: number;
206
280
  }
207
281
  /**
208
282
  * A ceiling in code of consultations defined as data, as `NhAssistantConsultationCeilingBuilder`
@@ -219,6 +293,8 @@ interface NhAssistantMockConsultationCeiling {
219
293
  maxTimeoutSeconds?: number;
220
294
  maxAnswerChars?: number;
221
295
  maxHistoryMessages?: number;
296
+ /** Every new consultation defined as data starts off until an administrator switches it on (`StartOff()`). */
297
+ startsOff?: boolean;
222
298
  }
223
299
  /** A consultation defined as data an agent of the scenario starts with. */
224
300
  interface NhAssistantMockDataConsultation extends DataConsultationRequest {
@@ -294,6 +370,12 @@ interface NhAssistantMockAdminScenario {
294
370
  * administration work per division, as an application that lists its divisions does.
295
371
  */
296
372
  runCatalog?: Partial<RunCatalog>;
373
+ /**
374
+ * The entries of agent metadata the application registers in code with `AddAgentMetadata`, which
375
+ * the run catalog lists as `agentMetadata`; the scenario's agents give their values in
376
+ * `metadata`, in code for an agent in code and stored for an agent created as data. Default none.
377
+ */
378
+ agentMetadata?: NhAssistantMockAgentMetadataEntry[];
297
379
  /**
298
380
  * Lets administrators define consultations as data within this ceiling, as `UseConsultationsAsData`
299
381
  * in code: agents created in the administration with run settings get it, and code agents with
@@ -301,6 +383,16 @@ interface NhAssistantMockAdminScenario {
301
383
  * `consultationCeiling`. Without it consultations exist in code only.
302
384
  */
303
385
  consultationsAsData?: NhAssistantMockConsultationCeiling;
386
+ /**
387
+ * Lets administrators define hand-offs as data within this ceiling, as `UseHandOffsAsData` in code.
388
+ * Without it hand-offs exist in code only.
389
+ */
390
+ handOffsAsData?: NhAssistantMockHandOffCeiling;
391
+ /**
392
+ * Lets administrators create shadow variants as data within this ceiling, as
393
+ * `UseShadowVariantsAsData` in code. Without it shadow variants exist in code only.
394
+ */
395
+ shadowVariantsAsData?: NhAssistantMockShadowVariantCeiling;
304
396
  /**
305
397
  * The data classifications each model profile and its fallbacks permit together, by profile name.
306
398
  * An agent or skill whose classification its profile does not permit is saved with the warning
@@ -325,6 +417,36 @@ interface NhAssistantMockAdminScenario {
325
417
  * unavailable and any id that does not start with `unknown` is accepted.
326
418
  */
327
419
  accounts?: AssistantAccount[];
420
+ /**
421
+ * The application's text assets for instructions, as its `INhAiTextAssetSource` supplies them
422
+ * (`UseTextAssetSource`): the run catalog reports `instructionAssets`, `GET admin/instruction-assets`
423
+ * lists them, and skills and agents created in the administration may name one instead of inline
424
+ * instructions. Without it the application offers none. Change them afterwards with
425
+ * `NhAssistantMockBackend.setInstructionAsset` and `removeInstructionAsset`.
426
+ */
427
+ instructionAssets?: NhAssistantMockInstructionAsset[];
428
+ /**
429
+ * Agent packages the host imported before the mock starts, in order, as `POST
430
+ * admin/agent-packages/import` imports them after the scenario's agents and run configurations:
431
+ * their parts are linked and the parts they lock show read-only. A package the import refuses fails
432
+ * the scenario at once.
433
+ */
434
+ agentPackages?: NhAssistantMockAgentPackage[];
435
+ }
436
+ /** An agent package the mock's host imported, with the options of its import. */
437
+ interface NhAssistantMockAgentPackage {
438
+ package: AgentPackage;
439
+ /** The technical account per agent whose run settings answer to one. */
440
+ serviceAccounts?: Record<string, string>;
441
+ }
442
+ /** One version of a text asset of the mock's application. */
443
+ interface NhAssistantMockInstructionAsset {
444
+ assetId: string;
445
+ version: number;
446
+ content: string;
447
+ /** The asset that replaces it, when the application deprecated it. */
448
+ replacedByAssetId?: string;
449
+ deprecatedAt?: string;
328
450
  }
329
451
  /** A person in the simulated organization. */
330
452
  interface NhAssistantMockPerson {
@@ -619,6 +741,20 @@ interface NhAssistantMockProposal {
619
741
  * with the asker's rights.
620
742
  */
621
743
  grantSource?: AgentGrantSource;
744
+ /**
745
+ * Whether the application executes the proposal's tool (`ExecuteInApplication` on the server).
746
+ * Default `false`. Approved, such a proposal waits as `awaiting-application` until its report is due,
747
+ * four hours later; an `execution-unknown` one is handed to the application again
748
+ * (`POST approvals/{id}/resolve` with `hand-to-application`) instead of running again.
749
+ */
750
+ executedByApplication?: boolean;
751
+ /**
752
+ * When the application's report is due, an ISO date, for a proposal listed as `awaiting-application`
753
+ * or `execution-unknown` that the application executes. Default four hours after it was made.
754
+ */
755
+ executionReportDueAt?: string | null;
756
+ /** The execution's result code, such as `report-overdue`. Default none. */
757
+ executionResultCode?: string | null;
622
758
  }
623
759
  /** One request the mock API received, for assertions in tests. */
624
760
  interface NhAssistantMockRequest {
@@ -687,6 +823,9 @@ declare class NhAssistantMockBackend {
687
823
  private readonly subjects;
688
824
  private readonly agentRuns;
689
825
  private readonly boards;
826
+ private readonly agentMetadata;
827
+ /** Agent packages: their endpoints, and the locks and links of every other administration request. */
828
+ private readonly agentPackages;
690
829
  private readonly canAdministerState;
691
830
  private readonly members;
692
831
  private readonly readPositions;
@@ -734,6 +873,13 @@ declare class NhAssistantMockBackend {
734
873
  * (`reauthorization-required`) or another authorization server (`issuer-changed`).
735
874
  */
736
875
  setMcpConnectionStatus(serverId: string, status: 'reauthorization-required' | 'issuer-changed'): void;
876
+ /**
877
+ * Publishes or changes one version of a text asset of the application. A skill or agent that names
878
+ * this version with another hash then reports `asset-changed`, as after the server's next load.
879
+ */
880
+ setInstructionAsset(asset: NhAssistantMockInstructionAsset): void;
881
+ /** Removes one version of a text asset; what names it reports `asset-missing`. */
882
+ removeInstructionAsset(assetId: string, version: number): void;
737
883
  /** The files people uploaded, oldest first, as the application's file source stored them. */
738
884
  get uploads(): readonly {
739
885
  conversationId: string;
@@ -807,6 +953,13 @@ declare class NhAssistantMockBackend {
807
953
  */
808
954
  private consultationsOf;
809
955
  private nextId;
956
+ /**
957
+ * The answer of an administration endpoint (`admin/...`) as its area gives it, with the groups of
958
+ * agents and the run catalog in the request's language, without the package locks and links.
959
+ */
960
+ private adminResult;
961
+ /** An administration request of the agent packages, as `adminResult` answers it, for a path with its query. */
962
+ private adminCall;
810
963
  /** An administration answer about agents with each agent's groups, as the server answers it. */
811
964
  private withGroups;
812
965
  private groupsOf;
@@ -864,4 +1017,4 @@ declare class NhAssistantMockLiveService implements NhAssistantLiveSurface {
864
1017
  declare function provideNhAssistantMockApi(script: NhAssistantMockScenario): EnvironmentProviders;
865
1018
 
866
1019
  export { NH_ASSISTANT_MOCK_HUB_PATH, NH_ASSISTANT_MOCK_SCENARIO, NhAssistantMockAuthorizationWindow, NhAssistantMockBackend, NhAssistantMockLiveService, provideNhAssistantMockApi };
867
- export type { NhAssistantMockAdminAgent, NhAssistantMockAdminScenario, NhAssistantMockAgentGroup, NhAssistantMockApprovalConsultation, NhAssistantMockApprovalStep, NhAssistantMockCollaboration, NhAssistantMockConnectionStep, NhAssistantMockConsultation, NhAssistantMockConsultationCeiling, NhAssistantMockDataConsultation, NhAssistantMockDataSkill, NhAssistantMockDataTrigger, NhAssistantMockDivision, NhAssistantMockErrorStep, NhAssistantMockFailStep, NhAssistantMockLiveMessage, NhAssistantMockMcpServer, NhAssistantMockPerson, NhAssistantMockProposal, NhAssistantMockRemoteTool, NhAssistantMockRequest, NhAssistantMockRun, NhAssistantMockRunConfigurationPreset, NhAssistantMockRunNow, NhAssistantMockScenario, NhAssistantMockStep, NhAssistantMockSubject, NhAssistantMockSubjectType, NhAssistantMockTextStep, NhAssistantMockTiming, NhAssistantMockToolStep, NhAssistantMockTurn, NhAssistantMockUpload };
1020
+ export type { NhAssistantMockAdminAgent, NhAssistantMockAdminScenario, NhAssistantMockAgentGroup, NhAssistantMockAgentMetadataEntry, NhAssistantMockAgentPackage, NhAssistantMockApprovalConsultation, NhAssistantMockApprovalStep, NhAssistantMockCodeHandOff, NhAssistantMockCollaboration, NhAssistantMockConnectionStep, NhAssistantMockConsultation, NhAssistantMockConsultationCeiling, NhAssistantMockDataConsultation, NhAssistantMockDataSkill, NhAssistantMockDataTrigger, NhAssistantMockDivision, NhAssistantMockErrorStep, NhAssistantMockFailStep, NhAssistantMockHandOffCeiling, NhAssistantMockHandOffRule, NhAssistantMockInstructionAsset, NhAssistantMockLiveMessage, NhAssistantMockMcpServer, NhAssistantMockPerson, NhAssistantMockProposal, NhAssistantMockRemoteTool, NhAssistantMockRequest, NhAssistantMockRun, NhAssistantMockRunConfigurationPreset, NhAssistantMockRunNow, NhAssistantMockScenario, NhAssistantMockShadowVariantCeiling, NhAssistantMockStep, NhAssistantMockSubject, NhAssistantMockSubjectType, NhAssistantMockTextStep, NhAssistantMockTiming, NhAssistantMockToolStep, NhAssistantMockTurn, NhAssistantMockUpload };