@healthcloudai/hc-ams 3.8.0 → 3.9.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/README.md CHANGED
@@ -23,6 +23,44 @@ const agents = await sdk.ams.getAgentsForTenant("<TENANT_ID>");
23
23
 
24
24
  ## Authentication
25
25
 
26
+ ### Native or custom HTTP transport
27
+
28
+ `HCAmsSDK` accepts an optional `fetch` adapter per instance. API, native V2 HTTP
29
+ and tenant-admin auth calls use that adapter; other SDK instances and global
30
+ fetch are unaffected. Without an adapter, the SDK uses global fetch at request
31
+ time as before. WebSocket construction remains the separate `WebSocketImpl` option.
32
+
33
+ An adapter accepts a resolved URL string and `RequestInit`, returning a standard
34
+ `Response`. It is a trusted transport: it must honor `AbortSignal` during headers
35
+ and body reads, and `redirect: "error"` before following redirects. The SDK also
36
+ rejects returned redirects, but that check cannot undo authority already sent by
37
+ an adapter that ignored redirect mode. Adapter errors never cause fallback or
38
+ automatic retries. Retain original V2 binding terms after uncertain outcomes.
39
+
40
+ For later Expo native host integration, use a named implementation rather than
41
+ replacing global networking:
42
+
43
+ ```ts
44
+ import { fetch as expoFetch } from "expo/fetch";
45
+ import { HCAmsSDK, type AmsFetch } from "@healthcloudai/hc-ams";
46
+
47
+ const nativeFetch: AmsFetch = (url, init) => expoFetch(url, {
48
+ method: init.method,
49
+ headers: init.headers,
50
+ body: init.body ?? undefined,
51
+ signal: init.signal ?? undefined,
52
+ redirect: "error",
53
+ credentials: "omit",
54
+ });
55
+ const sdk = new HCAmsSDK({ environment: "dev", fetch: nativeFetch });
56
+ ```
57
+
58
+ This hook alone does not qualify native Patient chat. The host still owns its
59
+ reviewed V2 endpoint, native HTTP/WSS Origin, ordinary Patient identity, UUID
60
+ generation, rendering, lifecycle and actual iOS/Android verification.
61
+
62
+ ### Patient and admin authority
63
+
26
64
  `ams.getAgentsForTenant` and native V2's `v2.listPublicAgents` / `v2.createRun`
27
65
  are public and require no access token. V2 public admission also requires an
28
66
  allowed browser Origin configured by the server.
package/dist/index.cjs CHANGED
@@ -193,7 +193,8 @@ var HttpClient = class {
193
193
  let response;
194
194
  let payload;
195
195
  try {
196
- response = await fetch(url, init);
196
+ const adapter = this.state.fetch;
197
+ response = adapter ? await adapter(url, init) : await globalThis.fetch(url, init);
197
198
  if (response.redirected || response.status >= 300 && response.status < 400 || response.type === "opaqueredirect") {
198
199
  throw new SDKError({ message: "Service redirects are not allowed", statusCode: response.status });
199
200
  }
@@ -1481,6 +1482,10 @@ var HCAmsSDK = class {
1481
1482
  var _a, _b;
1482
1483
  assertEnvironment(config.environment);
1483
1484
  assertTimeout((_a = config.timeout) != null ? _a : DEFAULT_TIMEOUT_MS);
1485
+ const adapter = config.fetch;
1486
+ if (adapter !== void 0 && typeof adapter !== "function") {
1487
+ throw new Error("Invalid HealthCloud SDK fetch adapter: expected a function.");
1488
+ }
1484
1489
  const apiBase = normalizeBaseUrl(
1485
1490
  config.baseUrlOverride === void 0 ? resolveBaseUrl(config.environment) : config.baseUrlOverride
1486
1491
  );
@@ -1495,7 +1500,8 @@ var HCAmsSDK = class {
1495
1500
  tenantId: config.tenantId,
1496
1501
  accessToken: config.accessToken,
1497
1502
  baseUrlOverride: apiBase,
1498
- timeout: (_b = config.timeout) != null ? _b : DEFAULT_TIMEOUT_MS
1503
+ timeout: (_b = config.timeout) != null ? _b : DEFAULT_TIMEOUT_MS,
1504
+ fetch: adapter
1499
1505
  };
1500
1506
  this.http = new HttpClient(this.state);
1501
1507
  const state = this.state;
@@ -1517,6 +1523,9 @@ var HCAmsSDK = class {
1517
1523
  },
1518
1524
  get timeout() {
1519
1525
  return state.timeout;
1526
+ },
1527
+ get fetch() {
1528
+ return state.fetch;
1520
1529
  }
1521
1530
  };
1522
1531
  this.authHttp = new HttpClient(authState);
package/dist/index.d.cts CHANGED
@@ -1,3 +1,25 @@
1
+ type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
2
+ /** Per-instance HTTP transport. Honor AbortSignal and refuse redirects before following them. */
3
+ type AmsFetch = (url: string, init: RequestInit) => Promise<Response>;
4
+ type QueryParamPrimitive = string | number | boolean | null | undefined;
5
+ type QueryParamValue = QueryParamPrimitive | QueryParamPrimitive[];
6
+ type QueryParams = Record<string, QueryParamValue>;
7
+ type JsonPrimitive = string | number | boolean | null;
8
+ type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
9
+ interface JsonObject {
10
+ [key: string]: JsonValue;
11
+ }
12
+ type HttpRequestBody = JsonPrimitive | object | FormData | Blob | ArrayBuffer | URLSearchParams;
13
+ interface HttpRequestOptions {
14
+ pathParams?: Record<string, string | number>;
15
+ query?: QueryParams;
16
+ body?: HttpRequestBody;
17
+ headers?: Record<string, string>;
18
+ auth?: boolean;
19
+ /** Overrides the SDK-configured timeout for this request. */
20
+ timeoutMs?: number;
21
+ }
22
+
1
23
  type Environment = "dev" | "uat" | "prod";
2
24
  /** The AMS service name used for URL resolution. */
3
25
  declare const SERVICE_NAME: "ams";
@@ -14,6 +36,8 @@ interface AmsSDKConfig {
14
36
  wssBaseUrlOverride?: string;
15
37
  /** Request timeout in milliseconds. Defaults to 30000 (30s). */
16
38
  timeout?: number;
39
+ /** Optional HTTP implementation for this instance; never replaces global fetch. */
40
+ fetch?: AmsFetch;
17
41
  }
18
42
  interface SDKRuntimeState {
19
43
  environment: Environment;
@@ -21,6 +45,7 @@ interface SDKRuntimeState {
21
45
  accessToken?: string;
22
46
  baseUrlOverride?: string;
23
47
  timeout: number;
48
+ fetch?: AmsFetch;
24
49
  }
25
50
  declare const DEFAULT_TIMEOUT_MS = 30000;
26
51
  /**
@@ -45,26 +70,6 @@ declare function resolveWssBaseUrl(environment: Environment): string;
45
70
  declare function assertEnvironment(environment: Environment): void;
46
71
  declare function assertTimeout(timeout: number, label?: string): void;
47
72
 
48
- type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
49
- type QueryParamPrimitive = string | number | boolean | null | undefined;
50
- type QueryParamValue = QueryParamPrimitive | QueryParamPrimitive[];
51
- type QueryParams = Record<string, QueryParamValue>;
52
- type JsonPrimitive = string | number | boolean | null;
53
- type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
54
- interface JsonObject {
55
- [key: string]: JsonValue;
56
- }
57
- type HttpRequestBody = JsonPrimitive | object | FormData | Blob | ArrayBuffer | URLSearchParams;
58
- interface HttpRequestOptions {
59
- pathParams?: Record<string, string | number>;
60
- query?: QueryParams;
61
- body?: HttpRequestBody;
62
- headers?: Record<string, string>;
63
- auth?: boolean;
64
- /** Overrides the SDK-configured timeout for this request. */
65
- timeoutMs?: number;
66
- }
67
-
68
73
  declare class HttpClient {
69
74
  private readonly state;
70
75
  private readonly baseUrl;
@@ -1366,4 +1371,4 @@ declare class SDKError extends Error {
1366
1371
  toString(): string;
1367
1372
  }
1368
1373
 
1369
- export { type AIAgent, type AIAgentCreate, type AIAgentUpdate, type AIDataSource, type AIGuardrail, type AIGuardrailCreate, type AIGuardrailUpdate, type AISkill, type AISkillCreate, type AISkillUpdate, type AITool, type ActivityEvent, type AgentMode, type AgentPreferredModel, type AgentStatus, type AgentTTSModel, type AgentType, AgentsClient, type AmsApplicationAgentsResponse, type AmsAuditableFields, AmsClient, type AmsSDKConfig, type AmsServiceName, type ArtifactBlockEvent, type AudioChunkEvent, type AudioInputFramePayload, AuthClient, type AuthMessageResponse, type AuthenticatedUser, type ChatEvent, type ChatFramePayload, type ConversationHistory, type ConversationHistoryEntry, DEFAULT_TIMEOUT_MS, DataSourcesClient, type Department, type DepartmentCreate, type DepartmentTeamEvaluation, type DepartmentUpdate, DepartmentsClient, type Environment, type ErrorEvent, type EventReplayEvent, GuardrailsClient, HCAmsSDK, type HandoffFramePayload, type HistoryEvent, type HttpMethod, type HttpRequestBody, type HttpRequestOptions, type JsonObject, type JsonPrimitive, type JsonValue, type LoginRequest, NativeV2Client, NativeV2WssClient, type NativeV2WssClientOptions, type NotificationEvent, type OutgoingFrameType, type PasswordResetConfirmRequest, type PasswordResetRequest, type PingEvent, PoliciesClient, type Policy, type PolicyCreate, type PolicyUpdate, type QueryParamPrimitive, type QueryParamValue, type QueryParams, type RegistrationRequest, type RegistrationResponse, type ResponseSuggestionsEvent, SDKError, type SDKRuntimeState, SERVICE_NAME, SkillsClient, type Team, type TeamCreate, type TeamUpdate, TeamsClient, type TestPatientCredentialCreate, type TestPatientCredentialEnvironment, type TestPatientCredentialResponse, type TestPatientCredentialUpdate, type TestPatientLoginResponse, TestPersonasClient, type TokenResponse, type ToolConfirmationFramePayload, type ToolResultEvent, ToolsClient, type TransferCandidate, type TransferEvent, type TurnCancelledEvent, type TurnCompletedEvent, type TurnFailedEvent, type TurnResult, type TurnStartedEvent, type V2Action, type V2ActionResult, type V2AdmissionOptions, type V2AuthOk, type V2BindPayload, type V2BookingAction, type V2BookingOutcome, type V2BookingResult, type V2CTAConfirmation, type V2ChatPayload, type V2ClientCapabilities, type V2Command, type V2Envelope, type V2EventMap, type V2EventType, type V2HistoryMessage, type V2Identity, type V2LoginAction, type V2OwnedRun, type V2PatientBindingOptions, type V2PatientBindingRequest, type V2PatientBindingResult, type V2Protocol, type V2PublicAgent, type V2PublicAgents, type V2ReplayFrame, type V2SignInOutcome, type V2SlotAction, type V2SlotResult, type V2Suggestions, type VadEvent, type VoiceFramePayload, type VoiceTranscriptEvent, type WebSocketImpl, type WebSocketLike, WssClient, type WssClientOptions, type WssEnvelopeFields, type WssEventMap, type WssEventType, type WssServerFrame, assertEnvironment, assertTimeout, resolveAmsAuthBaseUrl, resolveAmsOrigin, resolveBaseUrl, resolveWssBaseUrl };
1374
+ export { type AIAgent, type AIAgentCreate, type AIAgentUpdate, type AIDataSource, type AIGuardrail, type AIGuardrailCreate, type AIGuardrailUpdate, type AISkill, type AISkillCreate, type AISkillUpdate, type AITool, type ActivityEvent, type AgentMode, type AgentPreferredModel, type AgentStatus, type AgentTTSModel, type AgentType, AgentsClient, type AmsApplicationAgentsResponse, type AmsAuditableFields, AmsClient, type AmsFetch, type AmsSDKConfig, type AmsServiceName, type ArtifactBlockEvent, type AudioChunkEvent, type AudioInputFramePayload, AuthClient, type AuthMessageResponse, type AuthenticatedUser, type ChatEvent, type ChatFramePayload, type ConversationHistory, type ConversationHistoryEntry, DEFAULT_TIMEOUT_MS, DataSourcesClient, type Department, type DepartmentCreate, type DepartmentTeamEvaluation, type DepartmentUpdate, DepartmentsClient, type Environment, type ErrorEvent, type EventReplayEvent, GuardrailsClient, HCAmsSDK, type HandoffFramePayload, type HistoryEvent, type HttpMethod, type HttpRequestBody, type HttpRequestOptions, type JsonObject, type JsonPrimitive, type JsonValue, type LoginRequest, NativeV2Client, NativeV2WssClient, type NativeV2WssClientOptions, type NotificationEvent, type OutgoingFrameType, type PasswordResetConfirmRequest, type PasswordResetRequest, type PingEvent, PoliciesClient, type Policy, type PolicyCreate, type PolicyUpdate, type QueryParamPrimitive, type QueryParamValue, type QueryParams, type RegistrationRequest, type RegistrationResponse, type ResponseSuggestionsEvent, SDKError, type SDKRuntimeState, SERVICE_NAME, SkillsClient, type Team, type TeamCreate, type TeamUpdate, TeamsClient, type TestPatientCredentialCreate, type TestPatientCredentialEnvironment, type TestPatientCredentialResponse, type TestPatientCredentialUpdate, type TestPatientLoginResponse, TestPersonasClient, type TokenResponse, type ToolConfirmationFramePayload, type ToolResultEvent, ToolsClient, type TransferCandidate, type TransferEvent, type TurnCancelledEvent, type TurnCompletedEvent, type TurnFailedEvent, type TurnResult, type TurnStartedEvent, type V2Action, type V2ActionResult, type V2AdmissionOptions, type V2AuthOk, type V2BindPayload, type V2BookingAction, type V2BookingOutcome, type V2BookingResult, type V2CTAConfirmation, type V2ChatPayload, type V2ClientCapabilities, type V2Command, type V2Envelope, type V2EventMap, type V2EventType, type V2HistoryMessage, type V2Identity, type V2LoginAction, type V2OwnedRun, type V2PatientBindingOptions, type V2PatientBindingRequest, type V2PatientBindingResult, type V2Protocol, type V2PublicAgent, type V2PublicAgents, type V2ReplayFrame, type V2SignInOutcome, type V2SlotAction, type V2SlotResult, type V2Suggestions, type VadEvent, type VoiceFramePayload, type VoiceTranscriptEvent, type WebSocketImpl, type WebSocketLike, WssClient, type WssClientOptions, type WssEnvelopeFields, type WssEventMap, type WssEventType, type WssServerFrame, assertEnvironment, assertTimeout, resolveAmsAuthBaseUrl, resolveAmsOrigin, resolveBaseUrl, resolveWssBaseUrl };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,25 @@
1
+ type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
2
+ /** Per-instance HTTP transport. Honor AbortSignal and refuse redirects before following them. */
3
+ type AmsFetch = (url: string, init: RequestInit) => Promise<Response>;
4
+ type QueryParamPrimitive = string | number | boolean | null | undefined;
5
+ type QueryParamValue = QueryParamPrimitive | QueryParamPrimitive[];
6
+ type QueryParams = Record<string, QueryParamValue>;
7
+ type JsonPrimitive = string | number | boolean | null;
8
+ type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
9
+ interface JsonObject {
10
+ [key: string]: JsonValue;
11
+ }
12
+ type HttpRequestBody = JsonPrimitive | object | FormData | Blob | ArrayBuffer | URLSearchParams;
13
+ interface HttpRequestOptions {
14
+ pathParams?: Record<string, string | number>;
15
+ query?: QueryParams;
16
+ body?: HttpRequestBody;
17
+ headers?: Record<string, string>;
18
+ auth?: boolean;
19
+ /** Overrides the SDK-configured timeout for this request. */
20
+ timeoutMs?: number;
21
+ }
22
+
1
23
  type Environment = "dev" | "uat" | "prod";
2
24
  /** The AMS service name used for URL resolution. */
3
25
  declare const SERVICE_NAME: "ams";
@@ -14,6 +36,8 @@ interface AmsSDKConfig {
14
36
  wssBaseUrlOverride?: string;
15
37
  /** Request timeout in milliseconds. Defaults to 30000 (30s). */
16
38
  timeout?: number;
39
+ /** Optional HTTP implementation for this instance; never replaces global fetch. */
40
+ fetch?: AmsFetch;
17
41
  }
18
42
  interface SDKRuntimeState {
19
43
  environment: Environment;
@@ -21,6 +45,7 @@ interface SDKRuntimeState {
21
45
  accessToken?: string;
22
46
  baseUrlOverride?: string;
23
47
  timeout: number;
48
+ fetch?: AmsFetch;
24
49
  }
25
50
  declare const DEFAULT_TIMEOUT_MS = 30000;
26
51
  /**
@@ -45,26 +70,6 @@ declare function resolveWssBaseUrl(environment: Environment): string;
45
70
  declare function assertEnvironment(environment: Environment): void;
46
71
  declare function assertTimeout(timeout: number, label?: string): void;
47
72
 
48
- type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
49
- type QueryParamPrimitive = string | number | boolean | null | undefined;
50
- type QueryParamValue = QueryParamPrimitive | QueryParamPrimitive[];
51
- type QueryParams = Record<string, QueryParamValue>;
52
- type JsonPrimitive = string | number | boolean | null;
53
- type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
54
- interface JsonObject {
55
- [key: string]: JsonValue;
56
- }
57
- type HttpRequestBody = JsonPrimitive | object | FormData | Blob | ArrayBuffer | URLSearchParams;
58
- interface HttpRequestOptions {
59
- pathParams?: Record<string, string | number>;
60
- query?: QueryParams;
61
- body?: HttpRequestBody;
62
- headers?: Record<string, string>;
63
- auth?: boolean;
64
- /** Overrides the SDK-configured timeout for this request. */
65
- timeoutMs?: number;
66
- }
67
-
68
73
  declare class HttpClient {
69
74
  private readonly state;
70
75
  private readonly baseUrl;
@@ -1366,4 +1371,4 @@ declare class SDKError extends Error {
1366
1371
  toString(): string;
1367
1372
  }
1368
1373
 
1369
- export { type AIAgent, type AIAgentCreate, type AIAgentUpdate, type AIDataSource, type AIGuardrail, type AIGuardrailCreate, type AIGuardrailUpdate, type AISkill, type AISkillCreate, type AISkillUpdate, type AITool, type ActivityEvent, type AgentMode, type AgentPreferredModel, type AgentStatus, type AgentTTSModel, type AgentType, AgentsClient, type AmsApplicationAgentsResponse, type AmsAuditableFields, AmsClient, type AmsSDKConfig, type AmsServiceName, type ArtifactBlockEvent, type AudioChunkEvent, type AudioInputFramePayload, AuthClient, type AuthMessageResponse, type AuthenticatedUser, type ChatEvent, type ChatFramePayload, type ConversationHistory, type ConversationHistoryEntry, DEFAULT_TIMEOUT_MS, DataSourcesClient, type Department, type DepartmentCreate, type DepartmentTeamEvaluation, type DepartmentUpdate, DepartmentsClient, type Environment, type ErrorEvent, type EventReplayEvent, GuardrailsClient, HCAmsSDK, type HandoffFramePayload, type HistoryEvent, type HttpMethod, type HttpRequestBody, type HttpRequestOptions, type JsonObject, type JsonPrimitive, type JsonValue, type LoginRequest, NativeV2Client, NativeV2WssClient, type NativeV2WssClientOptions, type NotificationEvent, type OutgoingFrameType, type PasswordResetConfirmRequest, type PasswordResetRequest, type PingEvent, PoliciesClient, type Policy, type PolicyCreate, type PolicyUpdate, type QueryParamPrimitive, type QueryParamValue, type QueryParams, type RegistrationRequest, type RegistrationResponse, type ResponseSuggestionsEvent, SDKError, type SDKRuntimeState, SERVICE_NAME, SkillsClient, type Team, type TeamCreate, type TeamUpdate, TeamsClient, type TestPatientCredentialCreate, type TestPatientCredentialEnvironment, type TestPatientCredentialResponse, type TestPatientCredentialUpdate, type TestPatientLoginResponse, TestPersonasClient, type TokenResponse, type ToolConfirmationFramePayload, type ToolResultEvent, ToolsClient, type TransferCandidate, type TransferEvent, type TurnCancelledEvent, type TurnCompletedEvent, type TurnFailedEvent, type TurnResult, type TurnStartedEvent, type V2Action, type V2ActionResult, type V2AdmissionOptions, type V2AuthOk, type V2BindPayload, type V2BookingAction, type V2BookingOutcome, type V2BookingResult, type V2CTAConfirmation, type V2ChatPayload, type V2ClientCapabilities, type V2Command, type V2Envelope, type V2EventMap, type V2EventType, type V2HistoryMessage, type V2Identity, type V2LoginAction, type V2OwnedRun, type V2PatientBindingOptions, type V2PatientBindingRequest, type V2PatientBindingResult, type V2Protocol, type V2PublicAgent, type V2PublicAgents, type V2ReplayFrame, type V2SignInOutcome, type V2SlotAction, type V2SlotResult, type V2Suggestions, type VadEvent, type VoiceFramePayload, type VoiceTranscriptEvent, type WebSocketImpl, type WebSocketLike, WssClient, type WssClientOptions, type WssEnvelopeFields, type WssEventMap, type WssEventType, type WssServerFrame, assertEnvironment, assertTimeout, resolveAmsAuthBaseUrl, resolveAmsOrigin, resolveBaseUrl, resolveWssBaseUrl };
1374
+ export { type AIAgent, type AIAgentCreate, type AIAgentUpdate, type AIDataSource, type AIGuardrail, type AIGuardrailCreate, type AIGuardrailUpdate, type AISkill, type AISkillCreate, type AISkillUpdate, type AITool, type ActivityEvent, type AgentMode, type AgentPreferredModel, type AgentStatus, type AgentTTSModel, type AgentType, AgentsClient, type AmsApplicationAgentsResponse, type AmsAuditableFields, AmsClient, type AmsFetch, type AmsSDKConfig, type AmsServiceName, type ArtifactBlockEvent, type AudioChunkEvent, type AudioInputFramePayload, AuthClient, type AuthMessageResponse, type AuthenticatedUser, type ChatEvent, type ChatFramePayload, type ConversationHistory, type ConversationHistoryEntry, DEFAULT_TIMEOUT_MS, DataSourcesClient, type Department, type DepartmentCreate, type DepartmentTeamEvaluation, type DepartmentUpdate, DepartmentsClient, type Environment, type ErrorEvent, type EventReplayEvent, GuardrailsClient, HCAmsSDK, type HandoffFramePayload, type HistoryEvent, type HttpMethod, type HttpRequestBody, type HttpRequestOptions, type JsonObject, type JsonPrimitive, type JsonValue, type LoginRequest, NativeV2Client, NativeV2WssClient, type NativeV2WssClientOptions, type NotificationEvent, type OutgoingFrameType, type PasswordResetConfirmRequest, type PasswordResetRequest, type PingEvent, PoliciesClient, type Policy, type PolicyCreate, type PolicyUpdate, type QueryParamPrimitive, type QueryParamValue, type QueryParams, type RegistrationRequest, type RegistrationResponse, type ResponseSuggestionsEvent, SDKError, type SDKRuntimeState, SERVICE_NAME, SkillsClient, type Team, type TeamCreate, type TeamUpdate, TeamsClient, type TestPatientCredentialCreate, type TestPatientCredentialEnvironment, type TestPatientCredentialResponse, type TestPatientCredentialUpdate, type TestPatientLoginResponse, TestPersonasClient, type TokenResponse, type ToolConfirmationFramePayload, type ToolResultEvent, ToolsClient, type TransferCandidate, type TransferEvent, type TurnCancelledEvent, type TurnCompletedEvent, type TurnFailedEvent, type TurnResult, type TurnStartedEvent, type V2Action, type V2ActionResult, type V2AdmissionOptions, type V2AuthOk, type V2BindPayload, type V2BookingAction, type V2BookingOutcome, type V2BookingResult, type V2CTAConfirmation, type V2ChatPayload, type V2ClientCapabilities, type V2Command, type V2Envelope, type V2EventMap, type V2EventType, type V2HistoryMessage, type V2Identity, type V2LoginAction, type V2OwnedRun, type V2PatientBindingOptions, type V2PatientBindingRequest, type V2PatientBindingResult, type V2Protocol, type V2PublicAgent, type V2PublicAgents, type V2ReplayFrame, type V2SignInOutcome, type V2SlotAction, type V2SlotResult, type V2Suggestions, type VadEvent, type VoiceFramePayload, type VoiceTranscriptEvent, type WebSocketImpl, type WebSocketLike, WssClient, type WssClientOptions, type WssEnvelopeFields, type WssEventMap, type WssEventType, type WssServerFrame, assertEnvironment, assertTimeout, resolveAmsAuthBaseUrl, resolveAmsOrigin, resolveBaseUrl, resolveWssBaseUrl };
package/dist/index.js CHANGED
@@ -145,7 +145,8 @@ var HttpClient = class {
145
145
  let response;
146
146
  let payload;
147
147
  try {
148
- response = await fetch(url, init);
148
+ const adapter = this.state.fetch;
149
+ response = adapter ? await adapter(url, init) : await globalThis.fetch(url, init);
149
150
  if (response.redirected || response.status >= 300 && response.status < 400 || response.type === "opaqueredirect") {
150
151
  throw new SDKError({ message: "Service redirects are not allowed", statusCode: response.status });
151
152
  }
@@ -1433,6 +1434,10 @@ var HCAmsSDK = class {
1433
1434
  var _a, _b;
1434
1435
  assertEnvironment(config.environment);
1435
1436
  assertTimeout((_a = config.timeout) != null ? _a : DEFAULT_TIMEOUT_MS);
1437
+ const adapter = config.fetch;
1438
+ if (adapter !== void 0 && typeof adapter !== "function") {
1439
+ throw new Error("Invalid HealthCloud SDK fetch adapter: expected a function.");
1440
+ }
1436
1441
  const apiBase = normalizeBaseUrl(
1437
1442
  config.baseUrlOverride === void 0 ? resolveBaseUrl(config.environment) : config.baseUrlOverride
1438
1443
  );
@@ -1447,7 +1452,8 @@ var HCAmsSDK = class {
1447
1452
  tenantId: config.tenantId,
1448
1453
  accessToken: config.accessToken,
1449
1454
  baseUrlOverride: apiBase,
1450
- timeout: (_b = config.timeout) != null ? _b : DEFAULT_TIMEOUT_MS
1455
+ timeout: (_b = config.timeout) != null ? _b : DEFAULT_TIMEOUT_MS,
1456
+ fetch: adapter
1451
1457
  };
1452
1458
  this.http = new HttpClient(this.state);
1453
1459
  const state = this.state;
@@ -1469,6 +1475,9 @@ var HCAmsSDK = class {
1469
1475
  },
1470
1476
  get timeout() {
1471
1477
  return state.timeout;
1478
+ },
1479
+ get fetch() {
1480
+ return state.fetch;
1472
1481
  }
1473
1482
  };
1474
1483
  this.authHttp = new HttpClient(authState);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@healthcloudai/hc-ams",
3
- "version": "3.8.0",
3
+ "version": "3.9.0",
4
4
  "description": "HealthCloud AMS SDK \u2014 application-agent discovery for AMS Services.",
5
5
  "author": "Healthcheck Systems Inc",
6
6
  "license": "MIT",