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