@healthcloudai/hc-ams 0.0.1 → 3.5.1

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/dist/index.js CHANGED
@@ -5,6 +5,14 @@ function resolveBaseUrl(environment) {
5
5
  const prefix = environment === "prod" ? "" : `${environment}-`;
6
6
  return `https://${prefix}amsservices.health.cloud/api/ams`;
7
7
  }
8
+ function resolveAmsAuthBaseUrl(environment) {
9
+ const prefix = environment === "prod" ? "" : `${environment}-`;
10
+ return `https://${prefix}amsservices.health.cloud/api/auth`;
11
+ }
12
+ function resolveWssBaseUrl(environment) {
13
+ const prefix = environment === "prod" ? "" : `${environment}-`;
14
+ return `wss://${prefix}amsservices.health.cloud`;
15
+ }
8
16
  function assertEnvironment(environment) {
9
17
  if (environment !== "dev" && environment !== "uat" && environment !== "prod") {
10
18
  throw new Error(`Unsupported HealthCloud environment: "${environment}"`);
@@ -236,10 +244,631 @@ var AmsClient = class extends BaseServiceClient {
236
244
  }
237
245
  };
238
246
 
247
+ // src/clients/AgentsClient.ts
248
+ var AgentsClient = class extends BaseServiceClient {
249
+ constructor(http) {
250
+ super(http);
251
+ }
252
+ /** GET /agents */
253
+ list() {
254
+ return this.send("GET", "/agents");
255
+ }
256
+ /** GET /agents/{agent_id} */
257
+ get(agentId) {
258
+ return this.send("GET", "/agents/{agent_id}", {
259
+ pathParams: { agent_id: agentId }
260
+ });
261
+ }
262
+ /** POST /agents */
263
+ create(request) {
264
+ return this.send("POST", "/agents", { body: request });
265
+ }
266
+ /** PUT /agents/{agent_id} */
267
+ update(agentId, request) {
268
+ return this.send("PUT", "/agents/{agent_id}", {
269
+ pathParams: { agent_id: agentId },
270
+ body: request
271
+ });
272
+ }
273
+ /** DELETE /agents/{agent_id} */
274
+ delete(agentId) {
275
+ return this.send("DELETE", "/agents/{agent_id}", {
276
+ pathParams: { agent_id: agentId }
277
+ });
278
+ }
279
+ /** GET /agents/candidates — non-orchestrator agents eligible as transfer targets. */
280
+ listTransferCandidates() {
281
+ return this.send("GET", "/agents/candidates");
282
+ }
283
+ /**
284
+ * GET /agents/{agent_id}/conversation?session_id={tenant_id}/{patient_id}
285
+ *
286
+ * `sessionId` must be the literal `"{tenant_id}/{patient_id}"` string used
287
+ * to key the WSS session (see {@link "../wss/WssClient".WssClient}).
288
+ */
289
+ getConversation(agentId, sessionId) {
290
+ return this.send("GET", "/agents/{agent_id}/conversation", {
291
+ pathParams: { agent_id: agentId },
292
+ query: { session_id: sessionId }
293
+ });
294
+ }
295
+ /**
296
+ * DELETE /agents/{agent_id}/conversation?session_id={tenant_id}/{patient_id}
297
+ *
298
+ * Deletes both the persisted chat history and any live WSS session state
299
+ * for that session.
300
+ */
301
+ deleteConversation(agentId, sessionId) {
302
+ return this.send("DELETE", "/agents/{agent_id}/conversation", {
303
+ pathParams: { agent_id: agentId },
304
+ query: { session_id: sessionId }
305
+ });
306
+ }
307
+ };
308
+
309
+ // src/clients/DepartmentsClient.ts
310
+ var DepartmentsClient = class extends BaseServiceClient {
311
+ constructor(http) {
312
+ super(http);
313
+ }
314
+ /** GET /departments */
315
+ list() {
316
+ return this.send("GET", "/departments");
317
+ }
318
+ /** GET /departments/{department_id} */
319
+ get(departmentId) {
320
+ return this.send("GET", "/departments/{department_id}", {
321
+ pathParams: { department_id: departmentId }
322
+ });
323
+ }
324
+ /** POST /departments */
325
+ create(request) {
326
+ return this.send("POST", "/departments", { body: request });
327
+ }
328
+ /** PUT /departments/{department_id} */
329
+ update(departmentId, request) {
330
+ return this.send("PUT", "/departments/{department_id}", {
331
+ pathParams: { department_id: departmentId },
332
+ body: request
333
+ });
334
+ }
335
+ /** DELETE /departments/{department_id} */
336
+ delete(departmentId) {
337
+ return this.send("DELETE", "/departments/{department_id}", {
338
+ pathParams: { department_id: departmentId }
339
+ });
340
+ }
341
+ /** POST /departments/{department_id}/activate */
342
+ activate(departmentId) {
343
+ return this.send("POST", "/departments/{department_id}/activate", {
344
+ pathParams: { department_id: departmentId }
345
+ });
346
+ }
347
+ /** POST /departments/{department_id}/deactivate */
348
+ deactivate(departmentId) {
349
+ return this.send("POST", "/departments/{department_id}/deactivate", {
350
+ pathParams: { department_id: departmentId }
351
+ });
352
+ }
353
+ };
354
+
355
+ // src/clients/TeamsClient.ts
356
+ var TeamsClient = class extends BaseServiceClient {
357
+ constructor(http) {
358
+ super(http);
359
+ }
360
+ /** GET /teams */
361
+ list() {
362
+ return this.send("GET", "/teams");
363
+ }
364
+ /** GET /teams/{team_id} */
365
+ get(teamId) {
366
+ return this.send("GET", "/teams/{team_id}", {
367
+ pathParams: { team_id: teamId }
368
+ });
369
+ }
370
+ /** POST /teams */
371
+ create(request) {
372
+ return this.send("POST", "/teams", { body: request });
373
+ }
374
+ /** PUT /teams/{team_id} */
375
+ update(teamId, request) {
376
+ return this.send("PUT", "/teams/{team_id}", {
377
+ pathParams: { team_id: teamId },
378
+ body: request
379
+ });
380
+ }
381
+ /** DELETE /teams/{team_id} */
382
+ delete(teamId) {
383
+ return this.send("DELETE", "/teams/{team_id}", {
384
+ pathParams: { team_id: teamId }
385
+ });
386
+ }
387
+ };
388
+
389
+ // src/clients/SkillsClient.ts
390
+ var SkillsClient = class extends BaseServiceClient {
391
+ constructor(http) {
392
+ super(http);
393
+ }
394
+ /** GET /skills */
395
+ list() {
396
+ return this.send("GET", "/skills");
397
+ }
398
+ /** GET /skills/{skill_id} */
399
+ get(skillId) {
400
+ return this.send("GET", "/skills/{skill_id}", {
401
+ pathParams: { skill_id: skillId }
402
+ });
403
+ }
404
+ /** POST /skills */
405
+ create(request) {
406
+ return this.send("POST", "/skills", { body: request });
407
+ }
408
+ /** PUT /skills/{skill_id} */
409
+ update(skillId, request) {
410
+ return this.send("PUT", "/skills/{skill_id}", {
411
+ pathParams: { skill_id: skillId },
412
+ body: request
413
+ });
414
+ }
415
+ /** DELETE /skills/{skill_id} */
416
+ delete(skillId) {
417
+ return this.send("DELETE", "/skills/{skill_id}", {
418
+ pathParams: { skill_id: skillId }
419
+ });
420
+ }
421
+ };
422
+
423
+ // src/clients/PoliciesClient.ts
424
+ var PoliciesClient = class extends BaseServiceClient {
425
+ constructor(http) {
426
+ super(http);
427
+ }
428
+ /** GET /policies */
429
+ list() {
430
+ return this.send("GET", "/policies");
431
+ }
432
+ /** GET /policies/{policy_id} */
433
+ get(policyId) {
434
+ return this.send("GET", "/policies/{policy_id}", {
435
+ pathParams: { policy_id: policyId }
436
+ });
437
+ }
438
+ /** POST /policies */
439
+ create(request) {
440
+ return this.send("POST", "/policies", { body: request });
441
+ }
442
+ /** PUT /policies/{policy_id} */
443
+ update(policyId, request) {
444
+ return this.send("PUT", "/policies/{policy_id}", {
445
+ pathParams: { policy_id: policyId },
446
+ body: request
447
+ });
448
+ }
449
+ /** DELETE /policies/{policy_id} */
450
+ delete(policyId) {
451
+ return this.send("DELETE", "/policies/{policy_id}", {
452
+ pathParams: { policy_id: policyId }
453
+ });
454
+ }
455
+ };
456
+
457
+ // src/clients/GuardrailsClient.ts
458
+ var GuardrailsClient = class extends BaseServiceClient {
459
+ constructor(http) {
460
+ super(http);
461
+ }
462
+ /** GET /guardrails */
463
+ list() {
464
+ return this.send("GET", "/guardrails");
465
+ }
466
+ /** GET /guardrails/{guardrail_id} */
467
+ get(guardrailId) {
468
+ return this.send("GET", "/guardrails/{guardrail_id}", {
469
+ pathParams: { guardrail_id: guardrailId }
470
+ });
471
+ }
472
+ /** POST /guardrails */
473
+ create(request) {
474
+ return this.send("POST", "/guardrails", { body: request });
475
+ }
476
+ /** PUT /guardrails/{guardrail_id} */
477
+ update(guardrailId, request) {
478
+ return this.send("PUT", "/guardrails/{guardrail_id}", {
479
+ pathParams: { guardrail_id: guardrailId },
480
+ body: request
481
+ });
482
+ }
483
+ /** DELETE /guardrails/{guardrail_id} */
484
+ delete(guardrailId) {
485
+ return this.send("DELETE", "/guardrails/{guardrail_id}", {
486
+ pathParams: { guardrail_id: guardrailId }
487
+ });
488
+ }
489
+ };
490
+
491
+ // src/clients/DataSourcesClient.ts
492
+ var DataSourcesClient = class extends BaseServiceClient {
493
+ constructor(http) {
494
+ super(http);
495
+ }
496
+ /** GET /data-sources */
497
+ list() {
498
+ return this.send("GET", "/data-sources");
499
+ }
500
+ /** GET /data-sources/{data_source_id} */
501
+ get(dataSourceId) {
502
+ return this.send("GET", "/data-sources/{data_source_id}", {
503
+ pathParams: { data_source_id: dataSourceId }
504
+ });
505
+ }
506
+ };
507
+
508
+ // src/clients/ToolsClient.ts
509
+ var ToolsClient = class extends BaseServiceClient {
510
+ constructor(http) {
511
+ super(http);
512
+ }
513
+ /** GET /tools */
514
+ list() {
515
+ return this.send("GET", "/tools");
516
+ }
517
+ /** GET /tools/{tool_id} */
518
+ get(toolId) {
519
+ return this.send("GET", "/tools/{tool_id}", {
520
+ pathParams: { tool_id: toolId }
521
+ });
522
+ }
523
+ };
524
+
525
+ // src/clients/TestPersonasClient.ts
526
+ var TestPersonasClient = class extends BaseServiceClient {
527
+ constructor(http) {
528
+ super(http);
529
+ }
530
+ /** GET /test-patient-credentials */
531
+ list() {
532
+ return this.send("GET", "/test-patient-credentials");
533
+ }
534
+ /** GET /test-patient-credentials/{credential_id} */
535
+ get(credentialId) {
536
+ return this.send("GET", "/test-patient-credentials/{credential_id}", {
537
+ pathParams: { credential_id: credentialId }
538
+ });
539
+ }
540
+ /** POST /test-patient-credentials */
541
+ create(request) {
542
+ return this.send("POST", "/test-patient-credentials", { body: request });
543
+ }
544
+ /** PUT /test-patient-credentials/{credential_id} */
545
+ update(credentialId, request) {
546
+ return this.send("PUT", "/test-patient-credentials/{credential_id}", {
547
+ pathParams: { credential_id: credentialId },
548
+ body: request
549
+ });
550
+ }
551
+ /** DELETE /test-patient-credentials/{credential_id} */
552
+ delete(credentialId) {
553
+ return this.send("DELETE", "/test-patient-credentials/{credential_id}", {
554
+ pathParams: { credential_id: credentialId }
555
+ });
556
+ }
557
+ /**
558
+ * POST /test-patient-credentials/{credential_id}/login
559
+ *
560
+ * Logs this persona into Health Cloud and returns a real patient access
561
+ * token — feed `access_token`/`patient_id` into
562
+ * {@link "../wss/WssClient".WssClient} to open a chat session as this persona.
563
+ */
564
+ login(credentialId) {
565
+ return this.send("POST", "/test-patient-credentials/{credential_id}/login", {
566
+ pathParams: { credential_id: credentialId }
567
+ });
568
+ }
569
+ };
570
+
571
+ // src/clients/AuthClient.ts
572
+ var AuthClient = class extends BaseServiceClient {
573
+ constructor(http) {
574
+ super(http);
575
+ }
576
+ /** POST /api/auth/login (public) */
577
+ login(request) {
578
+ return this.send("POST", "/login", { body: request, auth: false });
579
+ }
580
+ /** POST /api/auth/reset-password (public) */
581
+ resetPassword(request) {
582
+ return this.send("POST", "/reset-password", { body: request, auth: false });
583
+ }
584
+ /** POST /api/auth/confirm-reset-password (public) */
585
+ confirmResetPassword(request) {
586
+ return this.send("POST", "/confirm-reset-password", { body: request, auth: false });
587
+ }
588
+ /** POST /api/auth/register (public) */
589
+ register(request) {
590
+ return this.send("POST", "/register", { body: request, auth: false });
591
+ }
592
+ /** GET /api/auth/me (Bearer required) */
593
+ me() {
594
+ return this.send("GET", "/me");
595
+ }
596
+ };
597
+
598
+ // src/wss/WssClient.ts
599
+ var WssClient = class {
600
+ constructor(options) {
601
+ this.options = options;
602
+ this.authenticated = false;
603
+ // Storage is necessarily untyped across the heterogeneous event map; `on`/`dispatch` restore type safety at the boundary.
604
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
605
+ this.listeners = /* @__PURE__ */ new Map();
606
+ var _a, _b, _c, _d;
607
+ if (options.healthcloudToken === void 0 && options.getAccessToken === void 0) {
608
+ throw new SDKError({
609
+ message: "WssClient requires either `healthcloudToken` or `getAccessToken`.",
610
+ statusCode: 0
611
+ });
612
+ }
613
+ const base = (_a = options.baseUrlOverride) != null ? _a : resolveWssBaseUrl(options.environment);
614
+ const sessionId = `${options.tenantId}/${options.patientId}`;
615
+ const path = options.agentId ? `/ws/agents/${encodeURIComponent(options.agentId)}/chat` : "/ws";
616
+ const url = new URL(`${base}${path}`);
617
+ url.searchParams.set("session_id", sessionId);
618
+ this.url = url.toString();
619
+ this.turnTimeoutMs = (_b = options.turnTimeoutMs) != null ? _b : 6e4;
620
+ this.authTimeoutMs = (_c = options.authTimeoutMs) != null ? _c : 1e4;
621
+ const ctor = (_d = options.WebSocketImpl) != null ? _d : globalThis.WebSocket;
622
+ if (!ctor) {
623
+ throw new SDKError({
624
+ message: 'No WebSocket implementation available. Pass `WebSocketImpl` (e.g. `new WssClient({ ..., WebSocketImpl: require("ws") })`) on runtimes without a global WebSocket (Node < 21).',
625
+ statusCode: 0
626
+ });
627
+ }
628
+ this.WebSocketCtor = ctor;
629
+ }
630
+ async resolveToken() {
631
+ var _a;
632
+ if (this.options.getAccessToken) {
633
+ return this.options.getAccessToken();
634
+ }
635
+ return (_a = this.options.healthcloudToken) != null ? _a : "";
636
+ }
637
+ /**
638
+ * Opens the socket and runs the auth handshake: sends
639
+ * `{"type":"auth","token":...}` as soon as the socket opens, and resolves
640
+ * only once the server replies `{"type":"auth_ok"}`. Rejects on a
641
+ * connect/auth error, an auth timeout, or a rejection frame — in every
642
+ * case before any chat frame can be sent (see {@link send}).
643
+ */
644
+ connect() {
645
+ return new Promise((resolve, reject) => {
646
+ this.authenticated = false;
647
+ const socket = new this.WebSocketCtor(this.url);
648
+ this.socket = socket;
649
+ let authTimer;
650
+ const settle = (fn) => {
651
+ cleanup();
652
+ fn();
653
+ };
654
+ const onOpen = () => {
655
+ authTimer = setTimeout(() => {
656
+ settle(
657
+ () => reject(new SDKError({ message: `Authentication timed out after ${this.authTimeoutMs}ms.`, statusCode: 0 }))
658
+ );
659
+ socket.close();
660
+ }, this.authTimeoutMs);
661
+ this.resolveToken().then((token) => socket.send(JSON.stringify({ type: "auth", token }))).catch((error) => {
662
+ clearTimeout(authTimer);
663
+ settle(
664
+ () => reject(
665
+ new SDKError({
666
+ message: "Failed to resolve the Health Cloud access token for the auth frame.",
667
+ statusCode: 0,
668
+ cause: error
669
+ })
670
+ )
671
+ );
672
+ socket.close();
673
+ });
674
+ };
675
+ const onError = (event) => {
676
+ clearTimeout(authTimer);
677
+ settle(() => reject(new SDKError({ message: "WebSocket connection failed.", statusCode: 0, cause: event })));
678
+ };
679
+ const onClose = (event) => {
680
+ clearTimeout(authTimer);
681
+ if (this.authenticated) return;
682
+ settle(
683
+ () => {
684
+ var _a, _b;
685
+ return reject(
686
+ new SDKError({
687
+ message: `WebSocket closed before authenticating (code ${(_a = event.code) != null ? _a : "unknown"}): ${(_b = event.reason) != null ? _b : ""}`.trim(),
688
+ statusCode: 0
689
+ })
690
+ );
691
+ }
692
+ );
693
+ };
694
+ const onMessage = (event) => {
695
+ var _a, _b;
696
+ if (!this.authenticated) {
697
+ let frame;
698
+ try {
699
+ frame = JSON.parse(String((_a = event.data) != null ? _a : ""));
700
+ } catch {
701
+ return;
702
+ }
703
+ if ((frame == null ? void 0 : frame.type) === "auth_ok") {
704
+ clearTimeout(authTimer);
705
+ this.authenticated = true;
706
+ settle(() => resolve());
707
+ return;
708
+ }
709
+ if ((frame == null ? void 0 : frame.type) === "error") {
710
+ clearTimeout(authTimer);
711
+ settle(
712
+ () => {
713
+ var _a2, _b2;
714
+ return reject(
715
+ new SDKError({
716
+ message: `WebSocket authentication was rejected: ${(_b2 = (_a2 = frame == null ? void 0 : frame.payload) == null ? void 0 : _a2.message) != null ? _b2 : "unknown error"}`,
717
+ statusCode: 401
718
+ })
719
+ );
720
+ }
721
+ );
722
+ return;
723
+ }
724
+ return;
725
+ }
726
+ this.dispatch((_b = event.data) != null ? _b : "");
727
+ };
728
+ const cleanup = () => {
729
+ socket.removeEventListener("open", onOpen);
730
+ socket.removeEventListener("error", onError);
731
+ socket.removeEventListener("close", onClose);
732
+ };
733
+ socket.addEventListener("open", onOpen);
734
+ socket.addEventListener("error", onError);
735
+ socket.addEventListener("close", onClose);
736
+ socket.addEventListener("message", onMessage);
737
+ });
738
+ }
739
+ /** Subscribes to a typed server event. Returns an unsubscribe function. */
740
+ on(type, handler) {
741
+ let set = this.listeners.get(type);
742
+ if (!set) {
743
+ set = /* @__PURE__ */ new Set();
744
+ this.listeners.set(type, set);
745
+ }
746
+ set.add(handler);
747
+ return () => set.delete(handler);
748
+ }
749
+ /** Sends a raw outgoing frame: `{"type": type, "payload": payload}`. */
750
+ send(type, payload = {}) {
751
+ if (!this.socket) {
752
+ throw new SDKError({ message: "WssClient is not connected. Call connect() first.", statusCode: 0 });
753
+ }
754
+ if (!this.authenticated) {
755
+ throw new SDKError({
756
+ message: "WssClient has not finished authenticating yet. Await connect() before sending frames.",
757
+ statusCode: 0
758
+ });
759
+ }
760
+ this.socket.send(JSON.stringify({ type, payload }));
761
+ }
762
+ sendChat(payload) {
763
+ this.send("chat", payload);
764
+ }
765
+ sendVoice(active) {
766
+ this.send("voice", { active });
767
+ }
768
+ sendAudioInput(payload) {
769
+ this.send("audio_input", payload);
770
+ }
771
+ sendToolConfirmation(payload) {
772
+ this.send("tool_confirmation", payload);
773
+ }
774
+ sendHandoff(messages) {
775
+ this.send("handoff", { messages });
776
+ }
777
+ /**
778
+ * Sends a `chat` frame and resolves once that turn completes, buffering
779
+ * every streamed `chat` delta into the final `message` and collecting
780
+ * `activity`/`transfer`/`artifact_block`/`notification`/`response_suggestions`
781
+ * events emitted during the turn.
782
+ *
783
+ * Resolves with `status: "failed"`/`"cancelled"` (rather than rejecting)
784
+ * on `turn_failed`/`turn_cancelled`, so callers can inspect whatever
785
+ * partial `message`/side-effects were collected before the turn ended.
786
+ * Rejects only if no terminal event arrives within `timeoutMs`.
787
+ */
788
+ sendAndAwaitTurn(content, opts = {}) {
789
+ const { timeoutMs = this.turnTimeoutMs, ...chatOpts } = opts;
790
+ return new Promise((resolve, reject) => {
791
+ let message = "";
792
+ const activity = [];
793
+ const transfers = [];
794
+ const artifacts = [];
795
+ const notifications = [];
796
+ let suggestions;
797
+ let turnId;
798
+ const unsubscribers = [];
799
+ const cleanup = () => {
800
+ clearTimeout(timer);
801
+ unsubscribers.forEach((unsub) => unsub());
802
+ };
803
+ const timer = setTimeout(() => {
804
+ cleanup();
805
+ reject(new SDKError({ message: `Turn timed out after ${timeoutMs}ms.`, statusCode: 0 }));
806
+ }, timeoutMs);
807
+ unsubscribers.push(
808
+ this.on("chat", (event) => {
809
+ var _a;
810
+ turnId = (_a = event.turn_id) != null ? _a : turnId;
811
+ if (event.replace) {
812
+ message = event.content;
813
+ } else {
814
+ message += event.content;
815
+ }
816
+ }),
817
+ this.on("activity", (event) => activity.push(event)),
818
+ this.on("transfer", (event) => transfers.push(event)),
819
+ this.on("artifact_block", (event) => artifacts.push(event)),
820
+ this.on("notification", (event) => notifications.push(event)),
821
+ this.on("response_suggestions", (event) => {
822
+ suggestions = event;
823
+ }),
824
+ this.on("turn_completed", (event) => {
825
+ var _a;
826
+ turnId = (_a = event.turn_id) != null ? _a : turnId;
827
+ cleanup();
828
+ resolve({ message, activity, transfers, artifacts, notifications, suggestions, turnId, status: "completed" });
829
+ }),
830
+ this.on("turn_failed", (event) => {
831
+ var _a;
832
+ turnId = (_a = event.turn_id) != null ? _a : turnId;
833
+ cleanup();
834
+ resolve({ message, activity, transfers, artifacts, notifications, suggestions, turnId, status: "failed" });
835
+ }),
836
+ this.on("turn_cancelled", (event) => {
837
+ var _a;
838
+ turnId = (_a = event.turn_id) != null ? _a : turnId;
839
+ cleanup();
840
+ resolve({ message, activity, transfers, artifacts, notifications, suggestions, turnId, status: "cancelled" });
841
+ })
842
+ );
843
+ this.sendChat({ content, ...chatOpts });
844
+ });
845
+ }
846
+ /** Closes the socket and clears all listeners. */
847
+ close(code, reason) {
848
+ var _a;
849
+ (_a = this.socket) == null ? void 0 : _a.close(code, reason);
850
+ this.authenticated = false;
851
+ this.listeners.clear();
852
+ }
853
+ dispatch(raw) {
854
+ let frame;
855
+ try {
856
+ frame = JSON.parse(raw);
857
+ } catch {
858
+ return;
859
+ }
860
+ const set = this.listeners.get(frame.type);
861
+ if (!set) return;
862
+ for (const handler of set) {
863
+ handler(frame.payload);
864
+ }
865
+ }
866
+ };
867
+
239
868
  // src/HCAmsSDK.ts
240
869
  var HCAmsSDK = class {
241
870
  constructor(config) {
242
- var _a, _b;
871
+ var _a, _b, _c;
243
872
  assertEnvironment(config.environment);
244
873
  assertTimeout((_a = config.timeout) != null ? _a : DEFAULT_TIMEOUT_MS);
245
874
  this.state = {
@@ -250,7 +879,60 @@ var HCAmsSDK = class {
250
879
  timeout: (_b = config.timeout) != null ? _b : DEFAULT_TIMEOUT_MS
251
880
  };
252
881
  this.http = new HttpClient(this.state);
882
+ const authBaseUrlOverride = (_c = config.baseUrlOverride) != null ? _c : resolveAmsAuthBaseUrl(config.environment);
883
+ const state = this.state;
884
+ const authState = {
885
+ get environment() {
886
+ return state.environment;
887
+ },
888
+ get tenantId() {
889
+ return state.tenantId;
890
+ },
891
+ get accessToken() {
892
+ return state.accessToken;
893
+ },
894
+ set accessToken(value) {
895
+ state.accessToken = value;
896
+ },
897
+ get baseUrlOverride() {
898
+ return authBaseUrlOverride;
899
+ },
900
+ get timeout() {
901
+ return state.timeout;
902
+ }
903
+ };
904
+ this.authHttp = new HttpClient(authState);
253
905
  this.ams = new AmsClient(this.http);
906
+ this.agents = new AgentsClient(this.http);
907
+ this.departments = new DepartmentsClient(this.http);
908
+ this.teams = new TeamsClient(this.http);
909
+ this.skills = new SkillsClient(this.http);
910
+ this.policies = new PoliciesClient(this.http);
911
+ this.guardrails = new GuardrailsClient(this.http);
912
+ this.dataSources = new DataSourcesClient(this.http);
913
+ this.tools = new ToolsClient(this.http);
914
+ this.testPersonas = new TestPersonasClient(this.http);
915
+ this.auth = new AuthClient(this.authHttp);
916
+ }
917
+ /**
918
+ * Opens a WebSocket agent-chat session using this SDK's configured
919
+ * environment (and `tenantId`, if set and not overridden here). See
920
+ * {@link WssClient} for the full API (typed event subscription,
921
+ * `sendAndAwaitTurn`, etc).
922
+ */
923
+ connectAgentChat(options) {
924
+ var _a;
925
+ const tenantId = (_a = options.tenantId) != null ? _a : this.state.tenantId;
926
+ if (!tenantId) {
927
+ throw new Error(
928
+ "connectAgentChat requires a tenantId \u2014 pass one explicitly or configure it on HCAmsSDK."
929
+ );
930
+ }
931
+ return new WssClient({
932
+ ...options,
933
+ environment: this.state.environment,
934
+ tenantId
935
+ });
254
936
  }
255
937
  /** Get the current runtime environment. */
256
938
  get environment() {
@@ -270,12 +952,25 @@ var HCAmsSDK = class {
270
952
  }
271
953
  };
272
954
  export {
955
+ AgentsClient,
273
956
  AmsClient,
957
+ AuthClient,
274
958
  DEFAULT_TIMEOUT_MS,
959
+ DataSourcesClient,
960
+ DepartmentsClient,
961
+ GuardrailsClient,
275
962
  HCAmsSDK,
963
+ PoliciesClient,
276
964
  SDKError,
277
965
  SERVICE_NAME,
966
+ SkillsClient,
967
+ TeamsClient,
968
+ TestPersonasClient,
969
+ ToolsClient,
970
+ WssClient,
278
971
  assertEnvironment,
279
972
  assertTimeout,
280
- resolveBaseUrl
973
+ resolveAmsAuthBaseUrl,
974
+ resolveBaseUrl,
975
+ resolveWssBaseUrl
281
976
  };