@healthcloudai/hc-ams 3.7.0 → 3.8.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/dist/index.cjs CHANGED
@@ -1059,6 +1059,7 @@ function capabilities(value) {
1059
1059
  }
1060
1060
 
1061
1061
  // src/v2/NativeV2Client.ts
1062
+ var BINDING_UNKNOWN = "V2 patient binding outcome unknown; reconcile the original operation.";
1062
1063
  var NativeV2Client = class {
1063
1064
  constructor(http) {
1064
1065
  this.http = http;
@@ -1077,6 +1078,65 @@ var NativeV2Client = class {
1077
1078
  ownedRun(result);
1078
1079
  return { run_id: result.run_id, run_secret: result.run_secret, protocol: result.protocol };
1079
1080
  }
1081
+ /**
1082
+ * Ordinary app sign-in. Close the socket after committed delivery first.
1083
+ * Sends once; callers retain the original UUID, claim and predecessor for retry.
1084
+ */
1085
+ async bindPatient(tenantId, agentId, runId, request, options) {
1086
+ let body;
1087
+ let headers;
1088
+ try {
1089
+ if (!record(request) || Object.keys(request).length !== 3 || !onlyKeys(request, ["operation_id", "run_secret", "expected_last_turn_id"]) || !record(options) || !onlyKeys(options, ["origin", "patientAccessToken"]) || !Object.prototype.hasOwnProperty.call(options, "patientAccessToken")) {
1090
+ throw invalid("Invalid V2 patient binding input.");
1091
+ }
1092
+ body = {
1093
+ operation_id: request.operation_id,
1094
+ run_secret: request.run_secret,
1095
+ expected_last_turn_id: request.expected_last_turn_id
1096
+ };
1097
+ const token = options.patientAccessToken;
1098
+ const origin = options.origin;
1099
+ if (!identity(tenantId) || !identity(agentId) || !uuid(runId) || !uuid(body.operation_id) || typeof body.run_secret !== "string" || !/^[A-Za-z0-9_-]{32,128}$/.test(body.run_secret) || !(body.expected_last_turn_id === null || uuid(body.expected_last_turn_id)) || typeof token !== "string" || !/^[!-~]{1,4096}$/.test(token)) {
1100
+ throw invalid("Invalid V2 patient binding input.");
1101
+ }
1102
+ headers = { Authorization: `Bearer ${token}` };
1103
+ if (origin !== void 0) {
1104
+ const parsed = new URL(origin);
1105
+ if (!["https:", "http:"].includes(parsed.protocol) || parsed.origin !== origin) {
1106
+ throw invalid("Invalid V2 patient binding input.");
1107
+ }
1108
+ headers.Origin = origin;
1109
+ }
1110
+ } catch {
1111
+ throw invalid("Invalid V2 patient binding input.");
1112
+ }
1113
+ let result;
1114
+ try {
1115
+ result = await this.http.request("POST", "/tenants/{tenant_id}/agents/{agent_id}/runs/{run_id}/patient-binding", {
1116
+ pathParams: { tenant_id: tenantId, agent_id: agentId, run_id: runId },
1117
+ auth: false,
1118
+ headers,
1119
+ body,
1120
+ timeoutMs: 1e4
1121
+ });
1122
+ } catch (error) {
1123
+ const code = error instanceof SDKError ? error.statusCode : 0;
1124
+ throw new SDKError({
1125
+ message: BINDING_UNKNOWN,
1126
+ statusCode: typeof code === "number" && Number.isInteger(code) && code >= 0 && code <= 599 ? code : 0
1127
+ });
1128
+ }
1129
+ if (!record(result) || result.status !== "bound" || !uuid(result.run_id) || result.run_id !== runId || !uuid(result.operation_id) || result.operation_id !== body.operation_id || typeof result.patient_id !== "string" || !/^[A-Za-z0-9_-]{1,160}$/.test(result.patient_id) || !(result.last_turn_id === null || uuid(result.last_turn_id)) || result.last_turn_id !== body.expected_last_turn_id) {
1130
+ throw new SDKError({ message: BINDING_UNKNOWN, statusCode: 0 });
1131
+ }
1132
+ return {
1133
+ status: "bound",
1134
+ run_id: result.run_id,
1135
+ operation_id: result.operation_id,
1136
+ patient_id: result.patient_id,
1137
+ last_turn_id: result.last_turn_id
1138
+ };
1139
+ }
1080
1140
  async request(method, path, tenantId, options, agentId) {
1081
1141
  if (options.origin !== void 0) {
1082
1142
  try {
package/dist/index.d.cts CHANGED
@@ -1009,6 +1009,20 @@ interface V2OwnedRun {
1009
1009
  run_secret: string;
1010
1010
  protocol: V2Protocol;
1011
1011
  }
1012
+ /** Original HTTP binding terms; retain privately and reuse unchanged after uncertainty. */
1013
+ interface V2PatientBindingRequest {
1014
+ operation_id: string;
1015
+ run_secret: string;
1016
+ expected_last_turn_id: string | null;
1017
+ }
1018
+ /** Patient identity is derived and verified by the server, never supplied by the host. */
1019
+ interface V2PatientBindingResult {
1020
+ status: "bound";
1021
+ run_id: string;
1022
+ operation_id: string;
1023
+ patient_id: string;
1024
+ last_turn_id: string | null;
1025
+ }
1012
1026
  interface V2ClientCapabilities {
1013
1027
  platform?: "web" | "ios" | "android" | "terminal" | "unknown";
1014
1028
  supported_actions?: Array<"confirm" | "insurance_scan" | "vitals_import" | "slot_picker" | "login" | "symptom_save" | "telehealth_join">;
@@ -1222,12 +1236,21 @@ interface V2AdmissionOptions {
1222
1236
  /** Allowed application origin for Node/native callers; browsers supply their own Origin. */
1223
1237
  origin?: string;
1224
1238
  }
1225
- /** Public Patient admission. Uses the SDK's selected AMS HTTP transport. */
1239
+ interface V2PatientBindingOptions extends V2AdmissionOptions {
1240
+ /** Explicit ordinary Patient authority; never the SDK's tenant-admin token. */
1241
+ patientAccessToken: string;
1242
+ }
1243
+ /** Native Patient admission and ordinary app binding through the selected AMS transport. */
1226
1244
  declare class NativeV2Client {
1227
1245
  private readonly http;
1228
1246
  constructor(http: HttpClient);
1229
1247
  listPublicAgents(tenantId: string, options?: V2AdmissionOptions): Promise<V2PublicAgents>;
1230
1248
  createRun(tenantId: string, agentId: string, options?: V2AdmissionOptions): Promise<V2OwnedRun>;
1249
+ /**
1250
+ * Ordinary app sign-in. Close the socket after committed delivery first.
1251
+ * Sends once; callers retain the original UUID, claim and predecessor for retry.
1252
+ */
1253
+ bindPatient(tenantId: string, agentId: string, runId: string, request: V2PatientBindingRequest, options: V2PatientBindingOptions): Promise<V2PatientBindingResult>;
1231
1254
  private request;
1232
1255
  }
1233
1256
 
@@ -1343,4 +1366,4 @@ declare class SDKError extends Error {
1343
1366
  toString(): string;
1344
1367
  }
1345
1368
 
1346
- 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 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -1009,6 +1009,20 @@ interface V2OwnedRun {
1009
1009
  run_secret: string;
1010
1010
  protocol: V2Protocol;
1011
1011
  }
1012
+ /** Original HTTP binding terms; retain privately and reuse unchanged after uncertainty. */
1013
+ interface V2PatientBindingRequest {
1014
+ operation_id: string;
1015
+ run_secret: string;
1016
+ expected_last_turn_id: string | null;
1017
+ }
1018
+ /** Patient identity is derived and verified by the server, never supplied by the host. */
1019
+ interface V2PatientBindingResult {
1020
+ status: "bound";
1021
+ run_id: string;
1022
+ operation_id: string;
1023
+ patient_id: string;
1024
+ last_turn_id: string | null;
1025
+ }
1012
1026
  interface V2ClientCapabilities {
1013
1027
  platform?: "web" | "ios" | "android" | "terminal" | "unknown";
1014
1028
  supported_actions?: Array<"confirm" | "insurance_scan" | "vitals_import" | "slot_picker" | "login" | "symptom_save" | "telehealth_join">;
@@ -1222,12 +1236,21 @@ interface V2AdmissionOptions {
1222
1236
  /** Allowed application origin for Node/native callers; browsers supply their own Origin. */
1223
1237
  origin?: string;
1224
1238
  }
1225
- /** Public Patient admission. Uses the SDK's selected AMS HTTP transport. */
1239
+ interface V2PatientBindingOptions extends V2AdmissionOptions {
1240
+ /** Explicit ordinary Patient authority; never the SDK's tenant-admin token. */
1241
+ patientAccessToken: string;
1242
+ }
1243
+ /** Native Patient admission and ordinary app binding through the selected AMS transport. */
1226
1244
  declare class NativeV2Client {
1227
1245
  private readonly http;
1228
1246
  constructor(http: HttpClient);
1229
1247
  listPublicAgents(tenantId: string, options?: V2AdmissionOptions): Promise<V2PublicAgents>;
1230
1248
  createRun(tenantId: string, agentId: string, options?: V2AdmissionOptions): Promise<V2OwnedRun>;
1249
+ /**
1250
+ * Ordinary app sign-in. Close the socket after committed delivery first.
1251
+ * Sends once; callers retain the original UUID, claim and predecessor for retry.
1252
+ */
1253
+ bindPatient(tenantId: string, agentId: string, runId: string, request: V2PatientBindingRequest, options: V2PatientBindingOptions): Promise<V2PatientBindingResult>;
1231
1254
  private request;
1232
1255
  }
1233
1256
 
@@ -1343,4 +1366,4 @@ declare class SDKError extends Error {
1343
1366
  toString(): string;
1344
1367
  }
1345
1368
 
1346
- 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 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 };
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 };
package/dist/index.js CHANGED
@@ -1011,6 +1011,7 @@ function capabilities(value) {
1011
1011
  }
1012
1012
 
1013
1013
  // src/v2/NativeV2Client.ts
1014
+ var BINDING_UNKNOWN = "V2 patient binding outcome unknown; reconcile the original operation.";
1014
1015
  var NativeV2Client = class {
1015
1016
  constructor(http) {
1016
1017
  this.http = http;
@@ -1029,6 +1030,65 @@ var NativeV2Client = class {
1029
1030
  ownedRun(result);
1030
1031
  return { run_id: result.run_id, run_secret: result.run_secret, protocol: result.protocol };
1031
1032
  }
1033
+ /**
1034
+ * Ordinary app sign-in. Close the socket after committed delivery first.
1035
+ * Sends once; callers retain the original UUID, claim and predecessor for retry.
1036
+ */
1037
+ async bindPatient(tenantId, agentId, runId, request, options) {
1038
+ let body;
1039
+ let headers;
1040
+ try {
1041
+ if (!record(request) || Object.keys(request).length !== 3 || !onlyKeys(request, ["operation_id", "run_secret", "expected_last_turn_id"]) || !record(options) || !onlyKeys(options, ["origin", "patientAccessToken"]) || !Object.prototype.hasOwnProperty.call(options, "patientAccessToken")) {
1042
+ throw invalid("Invalid V2 patient binding input.");
1043
+ }
1044
+ body = {
1045
+ operation_id: request.operation_id,
1046
+ run_secret: request.run_secret,
1047
+ expected_last_turn_id: request.expected_last_turn_id
1048
+ };
1049
+ const token = options.patientAccessToken;
1050
+ const origin = options.origin;
1051
+ if (!identity(tenantId) || !identity(agentId) || !uuid(runId) || !uuid(body.operation_id) || typeof body.run_secret !== "string" || !/^[A-Za-z0-9_-]{32,128}$/.test(body.run_secret) || !(body.expected_last_turn_id === null || uuid(body.expected_last_turn_id)) || typeof token !== "string" || !/^[!-~]{1,4096}$/.test(token)) {
1052
+ throw invalid("Invalid V2 patient binding input.");
1053
+ }
1054
+ headers = { Authorization: `Bearer ${token}` };
1055
+ if (origin !== void 0) {
1056
+ const parsed = new URL(origin);
1057
+ if (!["https:", "http:"].includes(parsed.protocol) || parsed.origin !== origin) {
1058
+ throw invalid("Invalid V2 patient binding input.");
1059
+ }
1060
+ headers.Origin = origin;
1061
+ }
1062
+ } catch {
1063
+ throw invalid("Invalid V2 patient binding input.");
1064
+ }
1065
+ let result;
1066
+ try {
1067
+ result = await this.http.request("POST", "/tenants/{tenant_id}/agents/{agent_id}/runs/{run_id}/patient-binding", {
1068
+ pathParams: { tenant_id: tenantId, agent_id: agentId, run_id: runId },
1069
+ auth: false,
1070
+ headers,
1071
+ body,
1072
+ timeoutMs: 1e4
1073
+ });
1074
+ } catch (error) {
1075
+ const code = error instanceof SDKError ? error.statusCode : 0;
1076
+ throw new SDKError({
1077
+ message: BINDING_UNKNOWN,
1078
+ statusCode: typeof code === "number" && Number.isInteger(code) && code >= 0 && code <= 599 ? code : 0
1079
+ });
1080
+ }
1081
+ if (!record(result) || result.status !== "bound" || !uuid(result.run_id) || result.run_id !== runId || !uuid(result.operation_id) || result.operation_id !== body.operation_id || typeof result.patient_id !== "string" || !/^[A-Za-z0-9_-]{1,160}$/.test(result.patient_id) || !(result.last_turn_id === null || uuid(result.last_turn_id)) || result.last_turn_id !== body.expected_last_turn_id) {
1082
+ throw new SDKError({ message: BINDING_UNKNOWN, statusCode: 0 });
1083
+ }
1084
+ return {
1085
+ status: "bound",
1086
+ run_id: result.run_id,
1087
+ operation_id: result.operation_id,
1088
+ patient_id: result.patient_id,
1089
+ last_turn_id: result.last_turn_id
1090
+ };
1091
+ }
1032
1092
  async request(method, path, tenantId, options, agentId) {
1033
1093
  if (options.origin !== void 0) {
1034
1094
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@healthcloudai/hc-ams",
3
- "version": "3.7.0",
3
+ "version": "3.8.0",
4
4
  "description": "HealthCloud AMS SDK \u2014 application-agent discovery for AMS Services.",
5
5
  "author": "Healthcheck Systems Inc",
6
6
  "license": "MIT",