@healthcloudai/hc-ams 3.6.5 → 3.7.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.d.cts CHANGED
@@ -24,8 +24,9 @@ interface SDKRuntimeState {
24
24
  }
25
25
  declare const DEFAULT_TIMEOUT_MS = 30000;
26
26
  /**
27
- * DEV uses the AWS AMS deployment. UAT/PROD retain their existing configuration;
28
- * all three AMS endpoint families use the same environment origin.
27
+ * DEV and PROD use the AWS AMS deployments. UAT keeps its existing hostname
28
+ * (no AWS UAT AMS host exists yet). All three AMS endpoint families (REST,
29
+ * auth, WSS) use the same environment origin.
29
30
  */
30
31
  declare function resolveAmsOrigin(environment: Environment): string;
31
32
  declare function resolveBaseUrl(environment: Environment): string;
@@ -992,6 +993,290 @@ declare class WssClient {
992
993
  private dispatch;
993
994
  }
994
995
 
996
+ /** Native owned-run protocols, independent of the legacy numeric-turn socket. */
997
+ type V2Protocol = "dbos_signin_v1" | "dbos_signin_cards_v1" | "dbos_signin_actions_v1" | "dbos_signin_booking_v1" | "dbos_signin_cta_v1";
998
+ interface V2PublicAgent {
999
+ id: string;
1000
+ name: string;
1001
+ protocol: V2Protocol;
1002
+ }
1003
+ interface V2PublicAgents {
1004
+ agents: V2PublicAgent[];
1005
+ }
1006
+ /** Keep this value in a private, in-memory holder. Never persist or log it. */
1007
+ interface V2OwnedRun {
1008
+ run_id: string;
1009
+ run_secret: string;
1010
+ protocol: V2Protocol;
1011
+ }
1012
+ interface V2ClientCapabilities {
1013
+ platform?: "web" | "ios" | "android" | "terminal" | "unknown";
1014
+ supported_actions?: Array<"confirm" | "insurance_scan" | "vitals_import" | "slot_picker" | "login" | "symptom_save" | "telehealth_join">;
1015
+ patient_flags_confirmation?: boolean;
1016
+ intake_confirmation?: boolean;
1017
+ encounter_confirmation?: boolean;
1018
+ locale?: string;
1019
+ time_zone?: string;
1020
+ }
1021
+ interface V2Envelope {
1022
+ event_seq?: number;
1023
+ turn_id?: string;
1024
+ agent_id?: string;
1025
+ timestamp?: string;
1026
+ }
1027
+ interface V2LoginAction {
1028
+ action_id: string;
1029
+ type: "login";
1030
+ payload: Record<string, never>;
1031
+ }
1032
+ interface V2SlotAction {
1033
+ action_id: string;
1034
+ type: "slot_picker";
1035
+ payload: {
1036
+ slot_ids: string[];
1037
+ slot_labels: Record<string, string>;
1038
+ };
1039
+ }
1040
+ interface V2BookingAction {
1041
+ action_id: string;
1042
+ type: "confirm";
1043
+ payload: {
1044
+ proposal_id: string;
1045
+ slot_id: string;
1046
+ reason: string;
1047
+ starts_at?: string | null;
1048
+ start_label?: string | null;
1049
+ display: {
1050
+ locale: string;
1051
+ time_zone: string;
1052
+ };
1053
+ };
1054
+ }
1055
+ type V2Action = V2LoginAction | V2SlotAction | V2BookingAction;
1056
+ interface V2SignInOutcome {
1057
+ action_id: string;
1058
+ patient_id: string;
1059
+ bound: true;
1060
+ }
1061
+ interface V2BookingOutcome {
1062
+ action_id: string;
1063
+ proposal_id: string;
1064
+ status: "done" | "unknown" | "cancelled";
1065
+ appointment_id?: string | null;
1066
+ }
1067
+ interface V2CTAConfirmation {
1068
+ offer_id: string;
1069
+ action: string;
1070
+ option_id: string;
1071
+ }
1072
+ interface V2Suggestions extends V2Envelope {
1073
+ mode: "single";
1074
+ question: string;
1075
+ options: Array<{
1076
+ id: string;
1077
+ label: string;
1078
+ cta_confirmation: V2CTAConfirmation;
1079
+ }>;
1080
+ }
1081
+ interface V2AuthOk {
1082
+ runtime: "dbos";
1083
+ run_id: string;
1084
+ patient_id: string | null;
1085
+ signin_outcome: V2SignInOutcome | null;
1086
+ booking_outcome?: V2BookingOutcome | null;
1087
+ response_suggestions?: V2Suggestions | null;
1088
+ last_turn_id: string | null;
1089
+ last_event_seq: number;
1090
+ pending_actions: V2Action[];
1091
+ protocol: V2Protocol;
1092
+ agent_ids: string[];
1093
+ agent_names: Record<string, string>;
1094
+ }
1095
+ interface V2HistoryMessage {
1096
+ role: "user" | "assistant" | "artifact" | "notification";
1097
+ content: string;
1098
+ agent_id?: string;
1099
+ [key: string]: unknown;
1100
+ }
1101
+ interface V2EventMap {
1102
+ auth_ok: V2AuthOk;
1103
+ history: {
1104
+ messages: V2HistoryMessage[];
1105
+ complete: boolean;
1106
+ };
1107
+ event_replay: {
1108
+ events: V2ReplayFrame[];
1109
+ complete: boolean;
1110
+ };
1111
+ chat: V2Envelope & {
1112
+ content: string;
1113
+ is_final: boolean;
1114
+ replace?: boolean;
1115
+ };
1116
+ action_request: V2Action & V2Envelope;
1117
+ turn_ack: {
1118
+ turn_id: string;
1119
+ event_seq: number;
1120
+ };
1121
+ turn_started: V2Envelope & {
1122
+ turn_id: string;
1123
+ };
1124
+ turn_completed: V2Envelope & {
1125
+ turn_id: string;
1126
+ signin_outcome?: V2SignInOutcome;
1127
+ booking_outcome?: V2BookingOutcome;
1128
+ };
1129
+ activity: V2Envelope & {
1130
+ label: string;
1131
+ kind: "tool" | "thinking";
1132
+ name?: string;
1133
+ status?: string;
1134
+ };
1135
+ transfer: V2Envelope & {
1136
+ from_agent_id: string;
1137
+ to_agent_id: string;
1138
+ mode?: string;
1139
+ agent_name?: string;
1140
+ message?: string;
1141
+ };
1142
+ artifact_block: V2Envelope & {
1143
+ kind: string;
1144
+ title: string;
1145
+ content: string;
1146
+ data?: Record<string, unknown>;
1147
+ };
1148
+ notification: V2Envelope & {
1149
+ title: string;
1150
+ message: string;
1151
+ level: string;
1152
+ type: string;
1153
+ };
1154
+ response_suggestions: V2Suggestions;
1155
+ error: V2Envelope & {
1156
+ code?: string;
1157
+ message: string;
1158
+ };
1159
+ ping: {
1160
+ ts: number;
1161
+ };
1162
+ close: {
1163
+ code?: number;
1164
+ };
1165
+ }
1166
+ type V2EventType = keyof V2EventMap;
1167
+ type V2ReplayFrame = {
1168
+ [K in Exclude<V2EventType, "auth_ok" | "history" | "event_replay" | "close">]: {
1169
+ type: K;
1170
+ payload: V2EventMap[K];
1171
+ };
1172
+ }[Exclude<V2EventType, "auth_ok" | "history" | "event_replay" | "close">];
1173
+ interface V2ChatPayload {
1174
+ content: string;
1175
+ turn_id: string;
1176
+ previous_turn_id: string | null;
1177
+ cta_confirmation?: V2CTAConfirmation;
1178
+ }
1179
+ interface V2BindPayload {
1180
+ action_id: string;
1181
+ tenant_id: string;
1182
+ patient_id: string;
1183
+ token: string;
1184
+ run_secret: string;
1185
+ identity_proof: string;
1186
+ turn_id: string;
1187
+ previous_turn_id: string;
1188
+ }
1189
+ interface V2SlotResult {
1190
+ action_id: string;
1191
+ status: "completed" | "cancelled" | "failed";
1192
+ data: {
1193
+ slot_id: string;
1194
+ } | Record<string, never>;
1195
+ turn_id: string;
1196
+ previous_turn_id: string;
1197
+ }
1198
+ interface V2BookingResult {
1199
+ action_id: string;
1200
+ status: "completed" | "cancelled" | "failed";
1201
+ data: {
1202
+ proposal_id: string;
1203
+ approved: boolean | null;
1204
+ };
1205
+ operation?: "confirm" | "status";
1206
+ turn_id: string;
1207
+ previous_turn_id: string;
1208
+ }
1209
+ type V2ActionResult = V2SlotResult | V2BookingResult;
1210
+ type V2Command = {
1211
+ type: "chat";
1212
+ payload: V2ChatPayload;
1213
+ } | {
1214
+ type: "bind_patient";
1215
+ payload: V2BindPayload;
1216
+ } | {
1217
+ type: "action_result";
1218
+ payload: V2ActionResult;
1219
+ };
1220
+
1221
+ interface V2AdmissionOptions {
1222
+ /** Allowed application origin for Node/native callers; browsers supply their own Origin. */
1223
+ origin?: string;
1224
+ }
1225
+ /** Public Patient admission. Uses the SDK's selected AMS HTTP transport. */
1226
+ declare class NativeV2Client {
1227
+ private readonly http;
1228
+ constructor(http: HttpClient);
1229
+ listPublicAgents(tenantId: string, options?: V2AdmissionOptions): Promise<V2PublicAgents>;
1230
+ createRun(tenantId: string, agentId: string, options?: V2AdmissionOptions): Promise<V2OwnedRun>;
1231
+ private request;
1232
+ }
1233
+
1234
+ type V2Identity = {
1235
+ kind: "anonymous";
1236
+ sessionId: string;
1237
+ } | {
1238
+ kind: "patient";
1239
+ patientId: string;
1240
+ getAccessToken: () => string | Promise<string>;
1241
+ };
1242
+ interface NativeV2WssClientOptions {
1243
+ environment: Environment;
1244
+ tenantId: string;
1245
+ agentId: string;
1246
+ run: V2OwnedRun;
1247
+ identity: V2Identity;
1248
+ /** Advertise only actions the host can actually render and handle. */
1249
+ capabilities?: V2ClientCapabilities;
1250
+ replaySince?: number;
1251
+ lang?: string;
1252
+ baseUrlOverride?: string;
1253
+ WebSocketImpl?: WebSocketImpl;
1254
+ /** Covers connection establishment, token refresh, and server admission. */
1255
+ authTimeoutMs?: number;
1256
+ }
1257
+ /**
1258
+ * Native V2 owned-run connection. No implicit run creation, retries, voice,
1259
+ * transcript handoff, or token persistence. Reconnect the same instance, or
1260
+ * retain the run claim and acknowledged cursor in the host's private holder.
1261
+ */
1262
+ declare class NativeV2WssClient {
1263
+ #private;
1264
+ constructor(options: NativeV2WssClientOptions);
1265
+ get lastTurnId(): string | null;
1266
+ get replaySince(): number;
1267
+ on<K extends V2EventType>(type: K, listener: (payload: V2EventMap[K]) => void): () => void;
1268
+ connect(): Promise<V2AuthOk>;
1269
+ close(): void;
1270
+ sendChat(payload: V2ChatPayload): Extract<V2Command, {
1271
+ type: "chat";
1272
+ }>;
1273
+ sendActionResult(payload: V2ActionResult): void;
1274
+ /** Offered-login socket binding; ordinary app sign-in uses its separate HTTP contract. */
1275
+ bindPatient(payload: V2BindPayload): void;
1276
+ /** Explicit retries resend the caller's original command identity and terms. */
1277
+ sendCommand(command: V2Command): void;
1278
+ }
1279
+
995
1280
  declare class HCAmsSDK {
996
1281
  private readonly state;
997
1282
  private readonly http;
@@ -999,6 +1284,8 @@ declare class HCAmsSDK {
999
1284
  private readonly wssBaseUrl;
1000
1285
  /** AMS application-agent discovery (public). */
1001
1286
  readonly ams: AmsClient;
1287
+ /** Explicit native V2 Patient discovery and owned-run admission. */
1288
+ readonly v2: NativeV2Client;
1002
1289
  /** Agent CRUD, transfer candidates, conversation history. */
1003
1290
  readonly agents: AgentsClient;
1004
1291
  /** Department CRUD. */
@@ -1029,6 +1316,10 @@ declare class HCAmsSDK {
1029
1316
  connectAgentChat(options: Omit<WssClientOptions, "environment" | "tenantId"> & {
1030
1317
  tenantId?: string;
1031
1318
  }): WssClient;
1319
+ /** Native V2 transport. The existing connectAgentChat remains the V1 API. */
1320
+ connectV2AgentChat(options: Omit<NativeV2WssClientOptions, "environment" | "tenantId"> & {
1321
+ tenantId?: string;
1322
+ }): NativeV2WssClient;
1032
1323
  /** Get the current runtime environment. */
1033
1324
  get environment(): string;
1034
1325
  /** Get the configured tenant ID. */
@@ -1052,4 +1343,4 @@ declare class SDKError extends Error {
1052
1343
  toString(): string;
1053
1344
  }
1054
1345
 
1055
- 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, 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 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -24,8 +24,9 @@ interface SDKRuntimeState {
24
24
  }
25
25
  declare const DEFAULT_TIMEOUT_MS = 30000;
26
26
  /**
27
- * DEV uses the AWS AMS deployment. UAT/PROD retain their existing configuration;
28
- * all three AMS endpoint families use the same environment origin.
27
+ * DEV and PROD use the AWS AMS deployments. UAT keeps its existing hostname
28
+ * (no AWS UAT AMS host exists yet). All three AMS endpoint families (REST,
29
+ * auth, WSS) use the same environment origin.
29
30
  */
30
31
  declare function resolveAmsOrigin(environment: Environment): string;
31
32
  declare function resolveBaseUrl(environment: Environment): string;
@@ -992,6 +993,290 @@ declare class WssClient {
992
993
  private dispatch;
993
994
  }
994
995
 
996
+ /** Native owned-run protocols, independent of the legacy numeric-turn socket. */
997
+ type V2Protocol = "dbos_signin_v1" | "dbos_signin_cards_v1" | "dbos_signin_actions_v1" | "dbos_signin_booking_v1" | "dbos_signin_cta_v1";
998
+ interface V2PublicAgent {
999
+ id: string;
1000
+ name: string;
1001
+ protocol: V2Protocol;
1002
+ }
1003
+ interface V2PublicAgents {
1004
+ agents: V2PublicAgent[];
1005
+ }
1006
+ /** Keep this value in a private, in-memory holder. Never persist or log it. */
1007
+ interface V2OwnedRun {
1008
+ run_id: string;
1009
+ run_secret: string;
1010
+ protocol: V2Protocol;
1011
+ }
1012
+ interface V2ClientCapabilities {
1013
+ platform?: "web" | "ios" | "android" | "terminal" | "unknown";
1014
+ supported_actions?: Array<"confirm" | "insurance_scan" | "vitals_import" | "slot_picker" | "login" | "symptom_save" | "telehealth_join">;
1015
+ patient_flags_confirmation?: boolean;
1016
+ intake_confirmation?: boolean;
1017
+ encounter_confirmation?: boolean;
1018
+ locale?: string;
1019
+ time_zone?: string;
1020
+ }
1021
+ interface V2Envelope {
1022
+ event_seq?: number;
1023
+ turn_id?: string;
1024
+ agent_id?: string;
1025
+ timestamp?: string;
1026
+ }
1027
+ interface V2LoginAction {
1028
+ action_id: string;
1029
+ type: "login";
1030
+ payload: Record<string, never>;
1031
+ }
1032
+ interface V2SlotAction {
1033
+ action_id: string;
1034
+ type: "slot_picker";
1035
+ payload: {
1036
+ slot_ids: string[];
1037
+ slot_labels: Record<string, string>;
1038
+ };
1039
+ }
1040
+ interface V2BookingAction {
1041
+ action_id: string;
1042
+ type: "confirm";
1043
+ payload: {
1044
+ proposal_id: string;
1045
+ slot_id: string;
1046
+ reason: string;
1047
+ starts_at?: string | null;
1048
+ start_label?: string | null;
1049
+ display: {
1050
+ locale: string;
1051
+ time_zone: string;
1052
+ };
1053
+ };
1054
+ }
1055
+ type V2Action = V2LoginAction | V2SlotAction | V2BookingAction;
1056
+ interface V2SignInOutcome {
1057
+ action_id: string;
1058
+ patient_id: string;
1059
+ bound: true;
1060
+ }
1061
+ interface V2BookingOutcome {
1062
+ action_id: string;
1063
+ proposal_id: string;
1064
+ status: "done" | "unknown" | "cancelled";
1065
+ appointment_id?: string | null;
1066
+ }
1067
+ interface V2CTAConfirmation {
1068
+ offer_id: string;
1069
+ action: string;
1070
+ option_id: string;
1071
+ }
1072
+ interface V2Suggestions extends V2Envelope {
1073
+ mode: "single";
1074
+ question: string;
1075
+ options: Array<{
1076
+ id: string;
1077
+ label: string;
1078
+ cta_confirmation: V2CTAConfirmation;
1079
+ }>;
1080
+ }
1081
+ interface V2AuthOk {
1082
+ runtime: "dbos";
1083
+ run_id: string;
1084
+ patient_id: string | null;
1085
+ signin_outcome: V2SignInOutcome | null;
1086
+ booking_outcome?: V2BookingOutcome | null;
1087
+ response_suggestions?: V2Suggestions | null;
1088
+ last_turn_id: string | null;
1089
+ last_event_seq: number;
1090
+ pending_actions: V2Action[];
1091
+ protocol: V2Protocol;
1092
+ agent_ids: string[];
1093
+ agent_names: Record<string, string>;
1094
+ }
1095
+ interface V2HistoryMessage {
1096
+ role: "user" | "assistant" | "artifact" | "notification";
1097
+ content: string;
1098
+ agent_id?: string;
1099
+ [key: string]: unknown;
1100
+ }
1101
+ interface V2EventMap {
1102
+ auth_ok: V2AuthOk;
1103
+ history: {
1104
+ messages: V2HistoryMessage[];
1105
+ complete: boolean;
1106
+ };
1107
+ event_replay: {
1108
+ events: V2ReplayFrame[];
1109
+ complete: boolean;
1110
+ };
1111
+ chat: V2Envelope & {
1112
+ content: string;
1113
+ is_final: boolean;
1114
+ replace?: boolean;
1115
+ };
1116
+ action_request: V2Action & V2Envelope;
1117
+ turn_ack: {
1118
+ turn_id: string;
1119
+ event_seq: number;
1120
+ };
1121
+ turn_started: V2Envelope & {
1122
+ turn_id: string;
1123
+ };
1124
+ turn_completed: V2Envelope & {
1125
+ turn_id: string;
1126
+ signin_outcome?: V2SignInOutcome;
1127
+ booking_outcome?: V2BookingOutcome;
1128
+ };
1129
+ activity: V2Envelope & {
1130
+ label: string;
1131
+ kind: "tool" | "thinking";
1132
+ name?: string;
1133
+ status?: string;
1134
+ };
1135
+ transfer: V2Envelope & {
1136
+ from_agent_id: string;
1137
+ to_agent_id: string;
1138
+ mode?: string;
1139
+ agent_name?: string;
1140
+ message?: string;
1141
+ };
1142
+ artifact_block: V2Envelope & {
1143
+ kind: string;
1144
+ title: string;
1145
+ content: string;
1146
+ data?: Record<string, unknown>;
1147
+ };
1148
+ notification: V2Envelope & {
1149
+ title: string;
1150
+ message: string;
1151
+ level: string;
1152
+ type: string;
1153
+ };
1154
+ response_suggestions: V2Suggestions;
1155
+ error: V2Envelope & {
1156
+ code?: string;
1157
+ message: string;
1158
+ };
1159
+ ping: {
1160
+ ts: number;
1161
+ };
1162
+ close: {
1163
+ code?: number;
1164
+ };
1165
+ }
1166
+ type V2EventType = keyof V2EventMap;
1167
+ type V2ReplayFrame = {
1168
+ [K in Exclude<V2EventType, "auth_ok" | "history" | "event_replay" | "close">]: {
1169
+ type: K;
1170
+ payload: V2EventMap[K];
1171
+ };
1172
+ }[Exclude<V2EventType, "auth_ok" | "history" | "event_replay" | "close">];
1173
+ interface V2ChatPayload {
1174
+ content: string;
1175
+ turn_id: string;
1176
+ previous_turn_id: string | null;
1177
+ cta_confirmation?: V2CTAConfirmation;
1178
+ }
1179
+ interface V2BindPayload {
1180
+ action_id: string;
1181
+ tenant_id: string;
1182
+ patient_id: string;
1183
+ token: string;
1184
+ run_secret: string;
1185
+ identity_proof: string;
1186
+ turn_id: string;
1187
+ previous_turn_id: string;
1188
+ }
1189
+ interface V2SlotResult {
1190
+ action_id: string;
1191
+ status: "completed" | "cancelled" | "failed";
1192
+ data: {
1193
+ slot_id: string;
1194
+ } | Record<string, never>;
1195
+ turn_id: string;
1196
+ previous_turn_id: string;
1197
+ }
1198
+ interface V2BookingResult {
1199
+ action_id: string;
1200
+ status: "completed" | "cancelled" | "failed";
1201
+ data: {
1202
+ proposal_id: string;
1203
+ approved: boolean | null;
1204
+ };
1205
+ operation?: "confirm" | "status";
1206
+ turn_id: string;
1207
+ previous_turn_id: string;
1208
+ }
1209
+ type V2ActionResult = V2SlotResult | V2BookingResult;
1210
+ type V2Command = {
1211
+ type: "chat";
1212
+ payload: V2ChatPayload;
1213
+ } | {
1214
+ type: "bind_patient";
1215
+ payload: V2BindPayload;
1216
+ } | {
1217
+ type: "action_result";
1218
+ payload: V2ActionResult;
1219
+ };
1220
+
1221
+ interface V2AdmissionOptions {
1222
+ /** Allowed application origin for Node/native callers; browsers supply their own Origin. */
1223
+ origin?: string;
1224
+ }
1225
+ /** Public Patient admission. Uses the SDK's selected AMS HTTP transport. */
1226
+ declare class NativeV2Client {
1227
+ private readonly http;
1228
+ constructor(http: HttpClient);
1229
+ listPublicAgents(tenantId: string, options?: V2AdmissionOptions): Promise<V2PublicAgents>;
1230
+ createRun(tenantId: string, agentId: string, options?: V2AdmissionOptions): Promise<V2OwnedRun>;
1231
+ private request;
1232
+ }
1233
+
1234
+ type V2Identity = {
1235
+ kind: "anonymous";
1236
+ sessionId: string;
1237
+ } | {
1238
+ kind: "patient";
1239
+ patientId: string;
1240
+ getAccessToken: () => string | Promise<string>;
1241
+ };
1242
+ interface NativeV2WssClientOptions {
1243
+ environment: Environment;
1244
+ tenantId: string;
1245
+ agentId: string;
1246
+ run: V2OwnedRun;
1247
+ identity: V2Identity;
1248
+ /** Advertise only actions the host can actually render and handle. */
1249
+ capabilities?: V2ClientCapabilities;
1250
+ replaySince?: number;
1251
+ lang?: string;
1252
+ baseUrlOverride?: string;
1253
+ WebSocketImpl?: WebSocketImpl;
1254
+ /** Covers connection establishment, token refresh, and server admission. */
1255
+ authTimeoutMs?: number;
1256
+ }
1257
+ /**
1258
+ * Native V2 owned-run connection. No implicit run creation, retries, voice,
1259
+ * transcript handoff, or token persistence. Reconnect the same instance, or
1260
+ * retain the run claim and acknowledged cursor in the host's private holder.
1261
+ */
1262
+ declare class NativeV2WssClient {
1263
+ #private;
1264
+ constructor(options: NativeV2WssClientOptions);
1265
+ get lastTurnId(): string | null;
1266
+ get replaySince(): number;
1267
+ on<K extends V2EventType>(type: K, listener: (payload: V2EventMap[K]) => void): () => void;
1268
+ connect(): Promise<V2AuthOk>;
1269
+ close(): void;
1270
+ sendChat(payload: V2ChatPayload): Extract<V2Command, {
1271
+ type: "chat";
1272
+ }>;
1273
+ sendActionResult(payload: V2ActionResult): void;
1274
+ /** Offered-login socket binding; ordinary app sign-in uses its separate HTTP contract. */
1275
+ bindPatient(payload: V2BindPayload): void;
1276
+ /** Explicit retries resend the caller's original command identity and terms. */
1277
+ sendCommand(command: V2Command): void;
1278
+ }
1279
+
995
1280
  declare class HCAmsSDK {
996
1281
  private readonly state;
997
1282
  private readonly http;
@@ -999,6 +1284,8 @@ declare class HCAmsSDK {
999
1284
  private readonly wssBaseUrl;
1000
1285
  /** AMS application-agent discovery (public). */
1001
1286
  readonly ams: AmsClient;
1287
+ /** Explicit native V2 Patient discovery and owned-run admission. */
1288
+ readonly v2: NativeV2Client;
1002
1289
  /** Agent CRUD, transfer candidates, conversation history. */
1003
1290
  readonly agents: AgentsClient;
1004
1291
  /** Department CRUD. */
@@ -1029,6 +1316,10 @@ declare class HCAmsSDK {
1029
1316
  connectAgentChat(options: Omit<WssClientOptions, "environment" | "tenantId"> & {
1030
1317
  tenantId?: string;
1031
1318
  }): WssClient;
1319
+ /** Native V2 transport. The existing connectAgentChat remains the V1 API. */
1320
+ connectV2AgentChat(options: Omit<NativeV2WssClientOptions, "environment" | "tenantId"> & {
1321
+ tenantId?: string;
1322
+ }): NativeV2WssClient;
1032
1323
  /** Get the current runtime environment. */
1033
1324
  get environment(): string;
1034
1325
  /** Get the configured tenant ID. */
@@ -1052,4 +1343,4 @@ declare class SDKError extends Error {
1052
1343
  toString(): string;
1053
1344
  }
1054
1345
 
1055
- 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, 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 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 };
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 };