@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/README.md +86 -1
- package/dist/index.cjs +501 -0
- package/dist/index.d.cts +314 -1
- package/dist/index.d.ts +314 -1
- package/dist/index.js +500 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,9 @@ const agents = await sdk.ams.getAgentsForTenant("<TENANT_ID>");
|
|
|
23
23
|
|
|
24
24
|
## Authentication
|
|
25
25
|
|
|
26
|
-
`ams.getAgentsForTenant`
|
|
26
|
+
`ams.getAgentsForTenant` and native V2's `v2.listPublicAgents` / `v2.createRun`
|
|
27
|
+
are public and require no access token. V2 public admission also requires an
|
|
28
|
+
allowed browser Origin configured by the server.
|
|
27
29
|
|
|
28
30
|
Every other REST client (`agents`, `departments`, `teams`, `skills`,
|
|
29
31
|
`policies`, `guardrails`, `dataSources`, `tools`, `testPersonas`) requires a
|
|
@@ -42,6 +44,7 @@ own patient auth flow in production.
|
|
|
42
44
|
| Client | Resource | Notes |
|
|
43
45
|
| --- | --- | --- |
|
|
44
46
|
| `sdk.ams` | Public application-agent discovery | No auth required |
|
|
47
|
+
| `sdk.v2` | Native V2 public discovery and owned-run creation | Explicit V2 endpoint; no staff token |
|
|
45
48
|
| `sdk.agents` | Agent CRUD, transfer candidates, conversation history | `create`/`update`/`delete` may 405 if the tenant has `disable_direct_agent_mutations` enabled (see below) |
|
|
46
49
|
| `sdk.departments` | Department CRUD + activate/deactivate | |
|
|
47
50
|
| `sdk.teams` | Team CRUD | |
|
|
@@ -224,6 +227,88 @@ department/team/agents/test-persona, logging in as the persona, and
|
|
|
224
227
|
validating a multi-turn conversation's turns, transfers, artifacts,
|
|
225
228
|
notifications, and activity.
|
|
226
229
|
|
|
230
|
+
## Native V2 owned runs
|
|
231
|
+
|
|
232
|
+
Use `connectV2AgentChat` for a native V2 service. `connectAgentChat` remains
|
|
233
|
+
the V1 API. Select the V2 REST base explicitly; WSS follows that origin unless
|
|
234
|
+
you supply an independent WSS proxy base.
|
|
235
|
+
|
|
236
|
+
```ts
|
|
237
|
+
const sdk = new HCAmsSDK({
|
|
238
|
+
environment: "dev",
|
|
239
|
+
tenantId: "healthcheck",
|
|
240
|
+
baseUrlOverride: "https://dev-ams-v2-services.health.cloud/api/ams",
|
|
241
|
+
});
|
|
242
|
+
const { agents } = await sdk.v2.listPublicAgents("healthcheck");
|
|
243
|
+
const agent = agents[0];
|
|
244
|
+
if (!agent) throw new Error("No public agent is available");
|
|
245
|
+
const run = await sdk.v2.createRun("healthcheck", agent.id);
|
|
246
|
+
const chat = sdk.connectV2AgentChat({
|
|
247
|
+
agentId: agent.id,
|
|
248
|
+
run,
|
|
249
|
+
identity: { kind: "anonymous", sessionId: crypto.randomUUID() },
|
|
250
|
+
capabilities: { platform: "web", supported_actions: ["login"] },
|
|
251
|
+
});
|
|
252
|
+
chat.on("action_request", action => {
|
|
253
|
+
// Render only capabilities that your host actually implements.
|
|
254
|
+
if (action.type === "login") showPatientSignIn(action.action_id);
|
|
255
|
+
});
|
|
256
|
+
chat.on("history", history => renderHistory(history.messages));
|
|
257
|
+
chat.on("chat", delta => renderAssistantDelta(delta));
|
|
258
|
+
const metadata = await chat.connect();
|
|
259
|
+
// auth_ok metadata and handlers are available before same-tick history/replay.
|
|
260
|
+
chat.sendChat({
|
|
261
|
+
content: "I would like help with an appointment",
|
|
262
|
+
turn_id: crypto.randomUUID(),
|
|
263
|
+
previous_turn_id: chat.lastTurnId,
|
|
264
|
+
});
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Keep `run` in a private in-memory host holder, together with the connection's
|
|
268
|
+
`replaySince` and acknowledged `lastTurnId`. The claim secret and patient token
|
|
269
|
+
travel only in the first auth frame, never in a URL. Do not log the run or put
|
|
270
|
+
its secret in browser storage, analytics, transcript handoff, or error details.
|
|
271
|
+
Clear the holder on logout, account replacement, or tenant/endpoint changes.
|
|
272
|
+
The client itself hides credentials from ordinary object serialization.
|
|
273
|
+
|
|
274
|
+
`connect()` resolves the typed `auth_ok` metadata, including pending actions,
|
|
275
|
+
protocol, last turn, and server event head. `on("event_replay", ...)` retains
|
|
276
|
+
the server's completeness flag; replayed events also reach their typed handlers
|
|
277
|
+
once per sequence. `turn_ack` advances the accepted predecessor. For an explicit
|
|
278
|
+
retry, retain the command returned by `sendChat` and pass it to `sendCommand`;
|
|
279
|
+
do not generate a replacement UUID or create another run after a disconnect.
|
|
280
|
+
There are no automatic reconnects or retries. Calling `connect()` again after
|
|
281
|
+
close uses the same claim and delivered cursor.
|
|
282
|
+
|
|
283
|
+
The same instance retains sent command terms in memory so an identical original
|
|
284
|
+
command can be retried after acknowledgment or reconnect. Reusing its turn ID
|
|
285
|
+
with changed terms is rejected. Discard the instance when discarding its run.
|
|
286
|
+
Event listener exceptions are isolated: they do not interrupt other listeners,
|
|
287
|
+
authentication, or connection cleanup. Hosts should handle their own observer errors.
|
|
288
|
+
|
|
289
|
+
Browsers supply their application Origin. Node/native callers can pass
|
|
290
|
+
`{ origin: "https://patient.example" }` as the last argument to
|
|
291
|
+
`listPublicAgents` and `createRun`; the server must allow that origin.
|
|
292
|
+
|
|
293
|
+
For an already-bound run, use
|
|
294
|
+
`identity: { kind: "patient", patientId, getAccessToken }`. The token provider
|
|
295
|
+
runs fresh for every connection. `bindPatient` implements the existing
|
|
296
|
+
**offered-login socket** command, including its action, identity proof, and
|
|
297
|
+
delivered predecessor. It does not implement ordinary app-initiated sign-in;
|
|
298
|
+
The backend now provides that separate HTTP contract; maintained SDK methods
|
|
299
|
+
and Patient/CLI integration remain follow-up work in AMS issues #1238 and #1240.
|
|
300
|
+
Preserve the same run through that flow.
|
|
301
|
+
|
|
302
|
+
`sendActionResult` supports the selected protocol's slot/booking wire commands;
|
|
303
|
+
it does not authorize a booking or establish that a tool is enabled. Advertise
|
|
304
|
+
only working host handlers and require server-issued terms and confirmation.
|
|
305
|
+
Binding requires advertised `login`; slot replies require `slot_picker`, and
|
|
306
|
+
booking confirmations/status commands require `confirm`.
|
|
307
|
+
Native V2 does not expose legacy voice/audio or transcript-handoff commands.
|
|
308
|
+
HTTP admission errors retain only a fixed message and status, without arbitrary
|
|
309
|
+
server bodies or transport causes. No endpoint switch or package publication
|
|
310
|
+
is performed by constructing this client.
|
|
311
|
+
|
|
227
312
|
## Configuration
|
|
228
313
|
|
|
229
314
|
| Option | Description |
|
package/dist/index.cjs
CHANGED
|
@@ -3,6 +3,9 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __typeError = (msg) => {
|
|
7
|
+
throw TypeError(msg);
|
|
8
|
+
};
|
|
6
9
|
var __export = (target, all) => {
|
|
7
10
|
for (var name in all)
|
|
8
11
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -16,6 +19,19 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
19
|
return to;
|
|
17
20
|
};
|
|
18
21
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
23
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
24
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
25
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
26
|
+
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
27
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
28
|
+
set _(value) {
|
|
29
|
+
__privateSet(obj, member, value, setter);
|
|
30
|
+
},
|
|
31
|
+
get _() {
|
|
32
|
+
return __privateGet(obj, member, getter);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
19
35
|
|
|
20
36
|
// src/index.ts
|
|
21
37
|
var index_exports = {};
|
|
@@ -28,6 +44,8 @@ __export(index_exports, {
|
|
|
28
44
|
DepartmentsClient: () => DepartmentsClient,
|
|
29
45
|
GuardrailsClient: () => GuardrailsClient,
|
|
30
46
|
HCAmsSDK: () => HCAmsSDK,
|
|
47
|
+
NativeV2Client: () => NativeV2Client,
|
|
48
|
+
NativeV2WssClient: () => NativeV2WssClient,
|
|
31
49
|
PoliciesClient: () => PoliciesClient,
|
|
32
50
|
SDKError: () => SDKError,
|
|
33
51
|
SERVICE_NAME: () => SERVICE_NAME,
|
|
@@ -989,6 +1007,474 @@ var WssClient = class {
|
|
|
989
1007
|
}
|
|
990
1008
|
};
|
|
991
1009
|
|
|
1010
|
+
// src/v2/validation.ts
|
|
1011
|
+
function invalid(message) {
|
|
1012
|
+
return new SDKError({ message, statusCode: 0 });
|
|
1013
|
+
}
|
|
1014
|
+
function record(value) {
|
|
1015
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1016
|
+
}
|
|
1017
|
+
function uuid(value) {
|
|
1018
|
+
return typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(value);
|
|
1019
|
+
}
|
|
1020
|
+
function identity(value) {
|
|
1021
|
+
return typeof value === "string" && /^[A-Za-z0-9_-]{1,128}$/.test(value);
|
|
1022
|
+
}
|
|
1023
|
+
function protocol(value) {
|
|
1024
|
+
return typeof value === "string" && [
|
|
1025
|
+
"dbos_signin_v1",
|
|
1026
|
+
"dbos_signin_cards_v1",
|
|
1027
|
+
"dbos_signin_actions_v1",
|
|
1028
|
+
"dbos_signin_booking_v1",
|
|
1029
|
+
"dbos_signin_cta_v1"
|
|
1030
|
+
].includes(value);
|
|
1031
|
+
}
|
|
1032
|
+
function cursor(value) {
|
|
1033
|
+
return Number.isSafeInteger(value) && value >= 0;
|
|
1034
|
+
}
|
|
1035
|
+
function ownedRun(value) {
|
|
1036
|
+
if (!record(value) || !uuid(value.run_id) || !protocol(value.protocol) || typeof value.run_secret !== "string" || value.run_secret.length < 32 || value.run_secret.length > 128) {
|
|
1037
|
+
throw invalid("Invalid V2 run credentials or protocol.");
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
function onlyKeys(value, allowed) {
|
|
1041
|
+
return Object.keys(value).every((key) => allowed.includes(key));
|
|
1042
|
+
}
|
|
1043
|
+
function capabilities(value) {
|
|
1044
|
+
if (!record(value) || !onlyKeys(value, [
|
|
1045
|
+
"platform",
|
|
1046
|
+
"supported_actions",
|
|
1047
|
+
"patient_flags_confirmation",
|
|
1048
|
+
"intake_confirmation",
|
|
1049
|
+
"encounter_confirmation",
|
|
1050
|
+
"locale",
|
|
1051
|
+
"time_zone"
|
|
1052
|
+
])) return false;
|
|
1053
|
+
if (value.platform !== void 0 && !["web", "ios", "android", "terminal", "unknown"].includes(value.platform)) return false;
|
|
1054
|
+
if (value.supported_actions !== void 0 && (!Array.isArray(value.supported_actions) || value.supported_actions.length > 16 || !value.supported_actions.every((action) => ["confirm", "insurance_scan", "vitals_import", "slot_picker", "login", "symptom_save", "telehealth_join"].includes(action)))) return false;
|
|
1055
|
+
for (const key of ["patient_flags_confirmation", "intake_confirmation", "encounter_confirmation"]) {
|
|
1056
|
+
if (value[key] !== void 0 && typeof value[key] !== "boolean") return false;
|
|
1057
|
+
}
|
|
1058
|
+
return ["locale", "time_zone"].every((key) => value[key] === void 0 || typeof value[key] === "string" && value[key].length > 0 && value[key].length <= 128);
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
// src/v2/NativeV2Client.ts
|
|
1062
|
+
var BINDING_UNKNOWN = "V2 patient binding outcome unknown; reconcile the original operation.";
|
|
1063
|
+
var NativeV2Client = class {
|
|
1064
|
+
constructor(http) {
|
|
1065
|
+
this.http = http;
|
|
1066
|
+
}
|
|
1067
|
+
async listPublicAgents(tenantId, options = {}) {
|
|
1068
|
+
if (!identity(tenantId)) throw invalid("Invalid V2 tenant identity.");
|
|
1069
|
+
const result = await this.request("GET", "/public/tenants/{tenant_id}/agents", tenantId, options);
|
|
1070
|
+
if (!record(result) || !Array.isArray(result.agents) || !result.agents.every((agent) => record(agent) && identity(agent.id) && typeof agent.name === "string" && protocol(agent.protocol))) {
|
|
1071
|
+
throw invalid("Invalid V2 public discovery response.");
|
|
1072
|
+
}
|
|
1073
|
+
return { agents: result.agents.map((agent) => ({ id: agent.id, name: agent.name, protocol: agent.protocol })) };
|
|
1074
|
+
}
|
|
1075
|
+
async createRun(tenantId, agentId, options = {}) {
|
|
1076
|
+
if (!identity(tenantId) || !identity(agentId)) throw invalid("Invalid V2 tenant or agent identity.");
|
|
1077
|
+
const result = await this.request("POST", "/public/tenants/{tenant_id}/agents/{agent_id}/runs", tenantId, options, agentId);
|
|
1078
|
+
ownedRun(result);
|
|
1079
|
+
return { run_id: result.run_id, run_secret: result.run_secret, protocol: result.protocol };
|
|
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
|
+
}
|
|
1140
|
+
async request(method, path, tenantId, options, agentId) {
|
|
1141
|
+
if (options.origin !== void 0) {
|
|
1142
|
+
try {
|
|
1143
|
+
const parsed = new URL(options.origin);
|
|
1144
|
+
if (!["https:", "http:"].includes(parsed.protocol) || parsed.origin !== options.origin) throw invalid("Invalid V2 admission origin.");
|
|
1145
|
+
} catch {
|
|
1146
|
+
throw invalid("Invalid V2 admission origin.");
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
try {
|
|
1150
|
+
return await this.http.request(method, path, {
|
|
1151
|
+
pathParams: { tenant_id: tenantId, ...agentId ? { agent_id: agentId } : {} },
|
|
1152
|
+
auth: false,
|
|
1153
|
+
...method === "POST" ? { body: {} } : {},
|
|
1154
|
+
...options.origin !== void 0 ? { headers: { Origin: options.origin } } : {}
|
|
1155
|
+
});
|
|
1156
|
+
} catch (error) {
|
|
1157
|
+
throw new SDKError({
|
|
1158
|
+
message: "V2 public admission request failed.",
|
|
1159
|
+
statusCode: error instanceof SDKError ? error.statusCode : 0
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1165
|
+
// src/v2/NativeV2WssClient.ts
|
|
1166
|
+
var _options, _socket, _ctor, _base, _authenticated, _lastTurn, _cursor, _sentCommands, _generation, _cleanup, _cancelConnect, _listeners, _NativeV2WssClient_instances, requireConnected_fn, validAuth_fn, receive_fn, dispatch_fn;
|
|
1167
|
+
var NativeV2WssClient = class {
|
|
1168
|
+
constructor(options) {
|
|
1169
|
+
__privateAdd(this, _NativeV2WssClient_instances);
|
|
1170
|
+
__privateAdd(this, _options);
|
|
1171
|
+
__privateAdd(this, _socket);
|
|
1172
|
+
__privateAdd(this, _ctor);
|
|
1173
|
+
__privateAdd(this, _base);
|
|
1174
|
+
__privateAdd(this, _authenticated, false);
|
|
1175
|
+
__privateAdd(this, _lastTurn, null);
|
|
1176
|
+
__privateAdd(this, _cursor);
|
|
1177
|
+
__privateAdd(this, _sentCommands, /* @__PURE__ */ new Map());
|
|
1178
|
+
__privateAdd(this, _generation, 0);
|
|
1179
|
+
__privateAdd(this, _cleanup);
|
|
1180
|
+
__privateAdd(this, _cancelConnect);
|
|
1181
|
+
__privateAdd(this, _listeners, /* @__PURE__ */ new Map());
|
|
1182
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1183
|
+
ownedRun(options.run);
|
|
1184
|
+
const owner = options.identity.kind === "anonymous" ? options.identity.sessionId : options.identity.patientId;
|
|
1185
|
+
if (!identity(options.tenantId) || !identity(options.agentId) || !identity(owner) || options.identity.kind !== "anonymous" && options.identity.kind !== "patient" || options.identity.kind === "patient" && typeof options.identity.getAccessToken !== "function" || !cursor((_a = options.replaySince) != null ? _a : 0)) throw invalid("Invalid V2 connection identity or replay cursor.");
|
|
1186
|
+
if (!capabilities((_b = options.capabilities) != null ? _b : {}) || options.lang !== void 0 && (typeof options.lang !== "string" || !options.lang || options.lang.length > 128)) throw invalid("Invalid V2 client capabilities or language.");
|
|
1187
|
+
assertTimeout((_c = options.authTimeoutMs) != null ? _c : 1e4, "authTimeoutMs");
|
|
1188
|
+
__privateSet(this, _base, normalizeWssBaseUrl((_d = options.baseUrlOverride) != null ? _d : resolveWssBaseUrl(options.environment)));
|
|
1189
|
+
const ctor = (_e = options.WebSocketImpl) != null ? _e : globalThis.WebSocket;
|
|
1190
|
+
if (!ctor) throw invalid("No WebSocket implementation available. Pass WebSocketImpl.");
|
|
1191
|
+
__privateSet(this, _ctor, ctor);
|
|
1192
|
+
__privateSet(this, _cursor, (_f = options.replaySince) != null ? _f : 0);
|
|
1193
|
+
__privateSet(this, _options, {
|
|
1194
|
+
...options,
|
|
1195
|
+
run: { ...options.run },
|
|
1196
|
+
identity: { ...options.identity },
|
|
1197
|
+
capabilities: JSON.parse(JSON.stringify((_g = options.capabilities) != null ? _g : {}))
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
get lastTurnId() {
|
|
1201
|
+
return __privateGet(this, _lastTurn);
|
|
1202
|
+
}
|
|
1203
|
+
get replaySince() {
|
|
1204
|
+
return __privateGet(this, _cursor);
|
|
1205
|
+
}
|
|
1206
|
+
on(type, listener) {
|
|
1207
|
+
if (!__privateGet(this, _listeners).has(type)) __privateGet(this, _listeners).set(type, /* @__PURE__ */ new Set());
|
|
1208
|
+
const entry = listener;
|
|
1209
|
+
__privateGet(this, _listeners).get(type).add(entry);
|
|
1210
|
+
return () => {
|
|
1211
|
+
var _a;
|
|
1212
|
+
(_a = __privateGet(this, _listeners).get(type)) == null ? void 0 : _a.delete(entry);
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
connect() {
|
|
1216
|
+
var _a;
|
|
1217
|
+
if (__privateGet(this, _socket) && __privateGet(this, _socket).readyState < 2) return Promise.reject(invalid("V2 connection is already active."));
|
|
1218
|
+
(_a = __privateGet(this, _cleanup)) == null ? void 0 : _a.call(this);
|
|
1219
|
+
__privateSet(this, _authenticated, false);
|
|
1220
|
+
const generation = ++__privateWrapper(this, _generation)._;
|
|
1221
|
+
const options = __privateGet(this, _options);
|
|
1222
|
+
const owner = options.identity.kind === "anonymous" ? options.identity.sessionId : options.identity.patientId;
|
|
1223
|
+
const url = new URL(joinServiceUrl(__privateGet(this, _base), `/ws/agents/${encodeURIComponent(options.agentId)}/chat`));
|
|
1224
|
+
url.searchParams.set("session_id", `${options.tenantId}/${owner}`);
|
|
1225
|
+
url.searchParams.set("transport", options.run.protocol);
|
|
1226
|
+
url.searchParams.set("run_id", options.run.run_id);
|
|
1227
|
+
url.searchParams.set("replay_since", String(__privateGet(this, _cursor)));
|
|
1228
|
+
if (options.identity.kind === "anonymous") url.searchParams.set("anonymous", "1");
|
|
1229
|
+
if (options.lang) url.searchParams.set("lang", options.lang);
|
|
1230
|
+
return new Promise((resolve, reject) => {
|
|
1231
|
+
var _a2;
|
|
1232
|
+
let socket;
|
|
1233
|
+
try {
|
|
1234
|
+
socket = new (__privateGet(this, _ctor))(url.toString());
|
|
1235
|
+
} catch {
|
|
1236
|
+
reject(invalid("V2 connection could not be opened."));
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
__privateSet(this, _socket, socket);
|
|
1240
|
+
let settled = false;
|
|
1241
|
+
let authSent = false;
|
|
1242
|
+
const current = () => generation === __privateGet(this, _generation) && socket === __privateGet(this, _socket);
|
|
1243
|
+
const timer = setTimeout(() => fail("Authentication timed out."), (_a2 = options.authTimeoutMs) != null ? _a2 : 1e4);
|
|
1244
|
+
const cleanup = () => {
|
|
1245
|
+
clearTimeout(timer);
|
|
1246
|
+
socket.removeEventListener("open", onOpen);
|
|
1247
|
+
socket.removeEventListener("message", onMessage);
|
|
1248
|
+
socket.removeEventListener("close", onClose);
|
|
1249
|
+
socket.removeEventListener("error", onError);
|
|
1250
|
+
};
|
|
1251
|
+
const fail = (message) => {
|
|
1252
|
+
if (!current()) return;
|
|
1253
|
+
clearTimeout(timer);
|
|
1254
|
+
if (!settled) {
|
|
1255
|
+
settled = true;
|
|
1256
|
+
reject(invalid(message));
|
|
1257
|
+
} else __privateMethod(this, _NativeV2WssClient_instances, dispatch_fn).call(this, "error", { code: "v2_transport_error", message });
|
|
1258
|
+
__privateSet(this, _authenticated, false);
|
|
1259
|
+
cleanup();
|
|
1260
|
+
__privateSet(this, _cancelConnect, void 0);
|
|
1261
|
+
socket.close();
|
|
1262
|
+
};
|
|
1263
|
+
const onOpen = () => {
|
|
1264
|
+
void (async () => {
|
|
1265
|
+
try {
|
|
1266
|
+
const token = options.identity.kind === "patient" ? await options.identity.getAccessToken() : "";
|
|
1267
|
+
if (!current() || settled || socket.readyState !== 1) return;
|
|
1268
|
+
if (typeof token !== "string" || token.length > 4096 || options.identity.kind === "patient" && !token) throw invalid("Invalid V2 access token.");
|
|
1269
|
+
socket.send(JSON.stringify({
|
|
1270
|
+
type: "auth",
|
|
1271
|
+
token,
|
|
1272
|
+
run_id: options.run.run_id,
|
|
1273
|
+
run_secret: options.run.run_secret,
|
|
1274
|
+
client: options.capabilities,
|
|
1275
|
+
...options.identity.kind === "patient" ? { patient_id: options.identity.patientId } : {}
|
|
1276
|
+
}));
|
|
1277
|
+
authSent = true;
|
|
1278
|
+
} catch {
|
|
1279
|
+
fail("V2 authentication credentials could not be resolved.");
|
|
1280
|
+
}
|
|
1281
|
+
})();
|
|
1282
|
+
};
|
|
1283
|
+
const onMessage = (event) => {
|
|
1284
|
+
if (!current()) return;
|
|
1285
|
+
let frame;
|
|
1286
|
+
try {
|
|
1287
|
+
if (typeof event.data !== "string" || event.data.length > 2 * 1024 * 1024) throw invalid("Invalid V2 frame.");
|
|
1288
|
+
frame = JSON.parse(event.data);
|
|
1289
|
+
if (!record(frame) || typeof frame.type !== "string" || !record(frame.payload)) throw invalid("Invalid V2 frame.");
|
|
1290
|
+
} catch {
|
|
1291
|
+
fail("Invalid V2 server message.");
|
|
1292
|
+
return;
|
|
1293
|
+
}
|
|
1294
|
+
if (!__privateGet(this, _authenticated)) {
|
|
1295
|
+
if (frame.type === "error") {
|
|
1296
|
+
fail("V2 authentication failed.");
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
if (frame.type !== "auth_ok") return;
|
|
1300
|
+
if (!authSent || !__privateMethod(this, _NativeV2WssClient_instances, validAuth_fn).call(this, frame.payload)) {
|
|
1301
|
+
fail("Invalid V2 authentication response.");
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
1304
|
+
const metadata = frame.payload;
|
|
1305
|
+
__privateSet(this, _lastTurn, metadata.last_turn_id);
|
|
1306
|
+
__privateSet(this, _authenticated, true);
|
|
1307
|
+
clearTimeout(timer);
|
|
1308
|
+
settled = true;
|
|
1309
|
+
__privateSet(this, _cancelConnect, void 0);
|
|
1310
|
+
__privateMethod(this, _NativeV2WssClient_instances, dispatch_fn).call(this, "auth_ok", metadata);
|
|
1311
|
+
resolve(metadata);
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
if (frame.type === "auth_ok") {
|
|
1315
|
+
fail("Unexpected V2 authentication response.");
|
|
1316
|
+
return;
|
|
1317
|
+
}
|
|
1318
|
+
__privateMethod(this, _NativeV2WssClient_instances, receive_fn).call(this, frame.type, frame.payload);
|
|
1319
|
+
};
|
|
1320
|
+
const onClose = (event) => {
|
|
1321
|
+
if (!current()) return;
|
|
1322
|
+
cleanup();
|
|
1323
|
+
__privateSet(this, _authenticated, false);
|
|
1324
|
+
__privateSet(this, _cancelConnect, void 0);
|
|
1325
|
+
if (!settled) {
|
|
1326
|
+
settled = true;
|
|
1327
|
+
reject(invalid("V2 connection closed before authentication."));
|
|
1328
|
+
}
|
|
1329
|
+
__privateMethod(this, _NativeV2WssClient_instances, dispatch_fn).call(this, "close", { code: event.code });
|
|
1330
|
+
};
|
|
1331
|
+
const onError = () => fail("V2 connection failed.");
|
|
1332
|
+
__privateSet(this, _cancelConnect, () => {
|
|
1333
|
+
if (!settled) {
|
|
1334
|
+
settled = true;
|
|
1335
|
+
reject(invalid("V2 connection closed before authentication."));
|
|
1336
|
+
}
|
|
1337
|
+
});
|
|
1338
|
+
__privateSet(this, _cleanup, cleanup);
|
|
1339
|
+
socket.addEventListener("open", onOpen);
|
|
1340
|
+
socket.addEventListener("message", onMessage);
|
|
1341
|
+
socket.addEventListener("close", onClose);
|
|
1342
|
+
socket.addEventListener("error", onError);
|
|
1343
|
+
});
|
|
1344
|
+
}
|
|
1345
|
+
close() {
|
|
1346
|
+
var _a, _b, _c;
|
|
1347
|
+
(_a = __privateGet(this, _cancelConnect)) == null ? void 0 : _a.call(this);
|
|
1348
|
+
__privateSet(this, _cancelConnect, void 0);
|
|
1349
|
+
++__privateWrapper(this, _generation)._;
|
|
1350
|
+
(_b = __privateGet(this, _cleanup)) == null ? void 0 : _b.call(this);
|
|
1351
|
+
__privateSet(this, _cleanup, void 0);
|
|
1352
|
+
__privateSet(this, _authenticated, false);
|
|
1353
|
+
(_c = __privateGet(this, _socket)) == null ? void 0 : _c.close();
|
|
1354
|
+
__privateSet(this, _socket, void 0);
|
|
1355
|
+
}
|
|
1356
|
+
sendChat(payload) {
|
|
1357
|
+
const command = { type: "chat", payload: { ...payload } };
|
|
1358
|
+
this.sendCommand(command);
|
|
1359
|
+
return command;
|
|
1360
|
+
}
|
|
1361
|
+
sendActionResult(payload) {
|
|
1362
|
+
this.sendCommand({ type: "action_result", payload });
|
|
1363
|
+
}
|
|
1364
|
+
/** Offered-login socket binding; ordinary app sign-in uses its separate HTTP contract. */
|
|
1365
|
+
bindPatient(payload) {
|
|
1366
|
+
this.sendCommand({ type: "bind_patient", payload });
|
|
1367
|
+
}
|
|
1368
|
+
/** Explicit retries resend the caller's original command identity and terms. */
|
|
1369
|
+
sendCommand(command) {
|
|
1370
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1371
|
+
__privateMethod(this, _NativeV2WssClient_instances, requireConnected_fn).call(this);
|
|
1372
|
+
if (!record(command) || !onlyKeys(command, ["type", "payload"]) || !record(command.payload)) {
|
|
1373
|
+
throw invalid("Invalid V2 command.");
|
|
1374
|
+
}
|
|
1375
|
+
const payload = command.payload;
|
|
1376
|
+
const serialized = JSON.stringify(command);
|
|
1377
|
+
const original = __privateGet(this, _sentCommands).get(payload.turn_id);
|
|
1378
|
+
if (!uuid(payload.turn_id) || !(payload.previous_turn_id === null || uuid(payload.previous_turn_id)) || payload.turn_id === payload.previous_turn_id || (original !== void 0 ? original !== serialized : payload.previous_turn_id !== __privateGet(this, _lastTurn))) {
|
|
1379
|
+
throw invalid("Invalid V2 command identity or predecessor.");
|
|
1380
|
+
}
|
|
1381
|
+
if (command.type === "chat") {
|
|
1382
|
+
if (!onlyKeys(payload, ["content", "turn_id", "previous_turn_id", "cta_confirmation"]) || typeof payload.content !== "string" || !payload.content.length || payload.content.length > 16384) throw invalid("Invalid V2 chat command.");
|
|
1383
|
+
if (payload.cta_confirmation !== void 0) {
|
|
1384
|
+
const choice = payload.cta_confirmation;
|
|
1385
|
+
if (__privateGet(this, _options).run.protocol !== "dbos_signin_cta_v1" || payload.previous_turn_id === null || !record(choice) || !onlyKeys(choice, ["offer_id", "action", "option_id"]) || typeof choice.offer_id !== "string" || !/^[0-9a-f]{32}$/.test(choice.offer_id) || typeof choice.action !== "string" || !/^[a-z0-9_-]{1,128}$/.test(choice.action) || ![`${choice.offer_id}:yes`, `${choice.offer_id}:no`].includes(choice.option_id)) throw invalid("Invalid V2 CTA confirmation.");
|
|
1386
|
+
}
|
|
1387
|
+
} else if (command.type === "bind_patient") {
|
|
1388
|
+
if (!((_b = (_a = __privateGet(this, _options).capabilities) == null ? void 0 : _a.supported_actions) == null ? void 0 : _b.includes("login"))) throw invalid("V2 login was not advertised.");
|
|
1389
|
+
if (!onlyKeys(payload, ["action_id", "tenant_id", "patient_id", "token", "run_secret", "identity_proof", "turn_id", "previous_turn_id"]) || !uuid(payload.action_id) || payload.previous_turn_id === null || payload.tenant_id !== __privateGet(this, _options).tenantId || !identity(payload.patient_id) || payload.run_secret !== __privateGet(this, _options).run.run_secret || typeof payload.token !== "string" || !payload.token || payload.token.length > 4096 || typeof payload.identity_proof !== "string" || !payload.identity_proof || payload.identity_proof.length > 2048) throw invalid("Invalid V2 binding command.");
|
|
1390
|
+
} else if (command.type === "action_result") {
|
|
1391
|
+
if (!onlyKeys(payload, ["action_id", "status", "data", "operation", "turn_id", "previous_turn_id"]) || !uuid(payload.action_id) || payload.previous_turn_id === null || !["completed", "cancelled", "failed"].includes(payload.status) || !record(payload.data)) throw invalid("Invalid V2 action command.");
|
|
1392
|
+
const data = payload.data;
|
|
1393
|
+
if ("proposal_id" in data) {
|
|
1394
|
+
if (!((_d = (_c = __privateGet(this, _options).capabilities) == null ? void 0 : _c.supported_actions) == null ? void 0 : _d.includes("confirm"))) throw invalid("V2 confirmation was not advertised.");
|
|
1395
|
+
if (__privateGet(this, _options).run.protocol !== "dbos_signin_booking_v1" || !onlyKeys(data, ["proposal_id", "approved"]) || !uuid(data.proposal_id) || ![void 0, "confirm", "status"].includes(payload.operation) || (payload.operation === "status" ? payload.status !== "completed" || data.approved !== null : typeof data.approved !== "boolean" || payload.status !== "completed" && data.approved)) throw invalid("Invalid V2 booking result.");
|
|
1396
|
+
} else if (!((_f = (_e = __privateGet(this, _options).capabilities) == null ? void 0 : _e.supported_actions) == null ? void 0 : _f.includes("slot_picker")) || !["dbos_signin_actions_v1", "dbos_signin_booking_v1", "dbos_signin_cta_v1"].includes(__privateGet(this, _options).run.protocol) || payload.operation !== void 0 || (payload.status === "completed" ? !onlyKeys(data, ["slot_id"]) || typeof data.slot_id !== "string" || !data.slot_id.length || data.slot_id.length > 256 : Object.keys(data).length > 0)) {
|
|
1397
|
+
throw invalid("Invalid V2 slot result.");
|
|
1398
|
+
}
|
|
1399
|
+
} else throw invalid("Unsupported V2 command.");
|
|
1400
|
+
__privateGet(this, _socket).send(serialized);
|
|
1401
|
+
__privateGet(this, _sentCommands).set(payload.turn_id, serialized);
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
_options = new WeakMap();
|
|
1405
|
+
_socket = new WeakMap();
|
|
1406
|
+
_ctor = new WeakMap();
|
|
1407
|
+
_base = new WeakMap();
|
|
1408
|
+
_authenticated = new WeakMap();
|
|
1409
|
+
_lastTurn = new WeakMap();
|
|
1410
|
+
_cursor = new WeakMap();
|
|
1411
|
+
_sentCommands = new WeakMap();
|
|
1412
|
+
_generation = new WeakMap();
|
|
1413
|
+
_cleanup = new WeakMap();
|
|
1414
|
+
_cancelConnect = new WeakMap();
|
|
1415
|
+
_listeners = new WeakMap();
|
|
1416
|
+
_NativeV2WssClient_instances = new WeakSet();
|
|
1417
|
+
requireConnected_fn = function() {
|
|
1418
|
+
var _a;
|
|
1419
|
+
if (!__privateGet(this, _authenticated) || ((_a = __privateGet(this, _socket)) == null ? void 0 : _a.readyState) !== 1) throw invalid("V2 connection is not authenticated.");
|
|
1420
|
+
};
|
|
1421
|
+
validAuth_fn = function(value) {
|
|
1422
|
+
const expectedPatient = __privateGet(this, _options).identity.kind === "patient" ? __privateGet(this, _options).identity.patientId : null;
|
|
1423
|
+
return value.runtime === "dbos" && value.run_id === __privateGet(this, _options).run.run_id && value.protocol === __privateGet(this, _options).run.protocol && value.patient_id === expectedPatient && (value.last_turn_id === null || uuid(value.last_turn_id)) && cursor(value.last_event_seq) && value.last_event_seq >= __privateGet(this, _cursor) && Array.isArray(value.pending_actions) && value.pending_actions.every((action) => record(action) && uuid(action.action_id) && ["login", "slot_picker", "confirm"].includes(action.type) && record(action.payload)) && Array.isArray(value.agent_ids) && value.agent_ids.every(identity) && record(value.agent_names) && Object.values(value.agent_names).every((name) => typeof name === "string");
|
|
1424
|
+
};
|
|
1425
|
+
receive_fn = function(type, payload) {
|
|
1426
|
+
if (type === "ping") {
|
|
1427
|
+
__privateGet(this, _socket).send(JSON.stringify({ type: "pong" }));
|
|
1428
|
+
__privateMethod(this, _NativeV2WssClient_instances, dispatch_fn).call(this, "ping", payload);
|
|
1429
|
+
return;
|
|
1430
|
+
}
|
|
1431
|
+
if (type === "event_replay") {
|
|
1432
|
+
if (!Array.isArray(payload.events) || typeof payload.complete !== "boolean") return;
|
|
1433
|
+
const events = [];
|
|
1434
|
+
for (const frame of payload.events) {
|
|
1435
|
+
if (record(frame) && typeof frame.type === "string" && record(frame.payload) && !["auth_ok", "history", "event_replay", "ping", "close"].includes(frame.type) && cursor(frame.payload.event_seq) && frame.payload.event_seq > __privateGet(this, _cursor)) {
|
|
1436
|
+
events.push(frame);
|
|
1437
|
+
__privateMethod(this, _NativeV2WssClient_instances, receive_fn).call(this, frame.type, frame.payload);
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
__privateMethod(this, _NativeV2WssClient_instances, dispatch_fn).call(this, "event_replay", { events, complete: payload.complete });
|
|
1441
|
+
return;
|
|
1442
|
+
}
|
|
1443
|
+
if (type === "turn_ack") {
|
|
1444
|
+
if (!uuid(payload.turn_id) || !cursor(payload.event_seq) || payload.event_seq < __privateGet(this, _cursor)) return;
|
|
1445
|
+
__privateSet(this, _lastTurn, payload.turn_id);
|
|
1446
|
+
__privateSet(this, _cursor, payload.event_seq);
|
|
1447
|
+
} else if (payload.event_seq !== void 0) {
|
|
1448
|
+
if (!cursor(payload.event_seq) || payload.event_seq <= __privateGet(this, _cursor)) return;
|
|
1449
|
+
__privateSet(this, _cursor, payload.event_seq);
|
|
1450
|
+
}
|
|
1451
|
+
if ([
|
|
1452
|
+
"history",
|
|
1453
|
+
"chat",
|
|
1454
|
+
"action_request",
|
|
1455
|
+
"turn_ack",
|
|
1456
|
+
"turn_started",
|
|
1457
|
+
"turn_completed",
|
|
1458
|
+
"activity",
|
|
1459
|
+
"transfer",
|
|
1460
|
+
"artifact_block",
|
|
1461
|
+
"notification",
|
|
1462
|
+
"response_suggestions",
|
|
1463
|
+
"error"
|
|
1464
|
+
].includes(type)) {
|
|
1465
|
+
__privateMethod(this, _NativeV2WssClient_instances, dispatch_fn).call(this, type, payload);
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
dispatch_fn = function(type, payload) {
|
|
1469
|
+
var _a;
|
|
1470
|
+
for (const listener of [...(_a = __privateGet(this, _listeners).get(type)) != null ? _a : []]) {
|
|
1471
|
+
try {
|
|
1472
|
+
listener(payload);
|
|
1473
|
+
} catch {
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
};
|
|
1477
|
+
|
|
992
1478
|
// src/HCAmsSDK.ts
|
|
993
1479
|
var HCAmsSDK = class {
|
|
994
1480
|
constructor(config) {
|
|
@@ -1035,6 +1521,7 @@ var HCAmsSDK = class {
|
|
|
1035
1521
|
};
|
|
1036
1522
|
this.authHttp = new HttpClient(authState);
|
|
1037
1523
|
this.ams = new AmsClient(this.http);
|
|
1524
|
+
this.v2 = new NativeV2Client(this.http);
|
|
1038
1525
|
this.agents = new AgentsClient(this.http);
|
|
1039
1526
|
this.departments = new DepartmentsClient(this.http);
|
|
1040
1527
|
this.teams = new TeamsClient(this.http);
|
|
@@ -1067,6 +1554,18 @@ var HCAmsSDK = class {
|
|
|
1067
1554
|
tenantId
|
|
1068
1555
|
});
|
|
1069
1556
|
}
|
|
1557
|
+
/** Native V2 transport. The existing connectAgentChat remains the V1 API. */
|
|
1558
|
+
connectV2AgentChat(options) {
|
|
1559
|
+
var _a, _b;
|
|
1560
|
+
const tenantId = (_a = options.tenantId) != null ? _a : this.state.tenantId;
|
|
1561
|
+
if (!tenantId) throw new Error("connectV2AgentChat requires a tenantId.");
|
|
1562
|
+
return new NativeV2WssClient({
|
|
1563
|
+
...options,
|
|
1564
|
+
environment: this.state.environment,
|
|
1565
|
+
tenantId,
|
|
1566
|
+
baseUrlOverride: (_b = options.baseUrlOverride) != null ? _b : this.wssBaseUrl
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1070
1569
|
/** Get the current runtime environment. */
|
|
1071
1570
|
get environment() {
|
|
1072
1571
|
return this.state.environment;
|
|
@@ -1094,6 +1593,8 @@ var HCAmsSDK = class {
|
|
|
1094
1593
|
DepartmentsClient,
|
|
1095
1594
|
GuardrailsClient,
|
|
1096
1595
|
HCAmsSDK,
|
|
1596
|
+
NativeV2Client,
|
|
1597
|
+
NativeV2WssClient,
|
|
1097
1598
|
PoliciesClient,
|
|
1098
1599
|
SDKError,
|
|
1099
1600
|
SERVICE_NAME,
|