@hol-org/rb-client 0.1.181 → 0.1.182
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +313 -6
- package/dist/index.d.cts +495 -105
- package/dist/index.d.ts +495 -105
- package/dist/index.js +313 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -286,12 +286,128 @@ var sessionEncryptionSummarySchema = import_zod2.z.object({
|
|
|
286
286
|
});
|
|
287
287
|
var chatHistoryEntrySchema = import_zod2.z.object({
|
|
288
288
|
messageId: import_zod2.z.string(),
|
|
289
|
-
role: import_zod2.z.enum([
|
|
289
|
+
role: import_zod2.z.enum([
|
|
290
|
+
"user",
|
|
291
|
+
"agent",
|
|
292
|
+
"system",
|
|
293
|
+
"tool",
|
|
294
|
+
"payment",
|
|
295
|
+
"delivery",
|
|
296
|
+
"error"
|
|
297
|
+
]),
|
|
290
298
|
content: import_zod2.z.string(),
|
|
291
299
|
timestamp: import_zod2.z.string(),
|
|
292
300
|
cipherEnvelope: cipherEnvelopeSchema.optional(),
|
|
293
301
|
metadata: import_zod2.z.record(jsonValueSchema).optional()
|
|
294
302
|
});
|
|
303
|
+
var chatDeliveryStateSchema = import_zod2.z.enum([
|
|
304
|
+
"draft",
|
|
305
|
+
"queued",
|
|
306
|
+
"persisted",
|
|
307
|
+
"delivered",
|
|
308
|
+
"streaming",
|
|
309
|
+
"responded",
|
|
310
|
+
"failed",
|
|
311
|
+
"timeout",
|
|
312
|
+
"cancelled"
|
|
313
|
+
]);
|
|
314
|
+
var chatReadinessStatusSchema = import_zod2.z.enum([
|
|
315
|
+
"responsive",
|
|
316
|
+
"delivery_only",
|
|
317
|
+
"degraded",
|
|
318
|
+
"blocked",
|
|
319
|
+
"unknown"
|
|
320
|
+
]);
|
|
321
|
+
var chatReplyModeSchema = import_zod2.z.enum([
|
|
322
|
+
"direct",
|
|
323
|
+
"stream",
|
|
324
|
+
"poll",
|
|
325
|
+
"delivery_only",
|
|
326
|
+
"none"
|
|
327
|
+
]);
|
|
328
|
+
var chatRouteTypeSchema = import_zod2.z.enum([
|
|
329
|
+
"a2a",
|
|
330
|
+
"hcs-10",
|
|
331
|
+
"mcp",
|
|
332
|
+
"openrouter",
|
|
333
|
+
"acp",
|
|
334
|
+
"xmtp",
|
|
335
|
+
"moltbook",
|
|
336
|
+
"agentverse",
|
|
337
|
+
"nanda",
|
|
338
|
+
"http",
|
|
339
|
+
"erc-8004",
|
|
340
|
+
"x402",
|
|
341
|
+
"unknown"
|
|
342
|
+
]);
|
|
343
|
+
var chatSessionStateSchema = import_zod2.z.enum([
|
|
344
|
+
"connecting",
|
|
345
|
+
"ready",
|
|
346
|
+
"blocked",
|
|
347
|
+
"ended",
|
|
348
|
+
"expired"
|
|
349
|
+
]);
|
|
350
|
+
var chatErrorCodeSchema = import_zod2.z.enum([
|
|
351
|
+
"AUTH_REQUIRED",
|
|
352
|
+
"CREDITS_REQUIRED",
|
|
353
|
+
"PAYMENT_REQUIRED",
|
|
354
|
+
"AGENT_UNRESPONSIVE",
|
|
355
|
+
"ROUTE_UNAVAILABLE",
|
|
356
|
+
"PROTOCOL_UNSUPPORTED",
|
|
357
|
+
"BROKER_NOT_EXECUTABLE",
|
|
358
|
+
"NETWORK_TIMEOUT",
|
|
359
|
+
"STREAM_STALLED",
|
|
360
|
+
"HISTORY_UNAVAILABLE",
|
|
361
|
+
"ENCRYPTION_REQUIRED",
|
|
362
|
+
"RATE_LIMITED",
|
|
363
|
+
"VALIDATION_ERROR",
|
|
364
|
+
"UNKNOWN_ERROR"
|
|
365
|
+
]);
|
|
366
|
+
var chatRouteSummarySchema = import_zod2.z.object({
|
|
367
|
+
type: chatRouteTypeSchema,
|
|
368
|
+
replyMode: chatReplyModeSchema,
|
|
369
|
+
transport: import_zod2.z.string(),
|
|
370
|
+
endpoint: import_zod2.z.string().optional()
|
|
371
|
+
});
|
|
372
|
+
var chatPaymentStateSchema = import_zod2.z.object({
|
|
373
|
+
required: import_zod2.z.boolean(),
|
|
374
|
+
provider: import_zod2.z.enum(["credits", "x402", "acp", "openrouter"]).optional(),
|
|
375
|
+
status: import_zod2.z.enum([
|
|
376
|
+
"not_required",
|
|
377
|
+
"preflight",
|
|
378
|
+
"required",
|
|
379
|
+
"approved",
|
|
380
|
+
"paid",
|
|
381
|
+
"failed"
|
|
382
|
+
]),
|
|
383
|
+
estimatedCredits: import_zod2.z.number().nullable().optional(),
|
|
384
|
+
estimatedUsd: import_zod2.z.number().nullable().optional()
|
|
385
|
+
});
|
|
386
|
+
var chatReadinessResponseSchema = import_zod2.z.object({
|
|
387
|
+
status: chatReadinessStatusSchema,
|
|
388
|
+
routeType: chatRouteTypeSchema,
|
|
389
|
+
replyMode: chatReplyModeSchema,
|
|
390
|
+
transport: import_zod2.z.string(),
|
|
391
|
+
endpoint: import_zod2.z.string().optional(),
|
|
392
|
+
checkedAt: import_zod2.z.string(),
|
|
393
|
+
cachedUntil: import_zod2.z.string(),
|
|
394
|
+
latencyMs: import_zod2.z.number().nullable().optional(),
|
|
395
|
+
lastSuccessfulReplyAt: import_zod2.z.string().nullable().optional(),
|
|
396
|
+
lastDeliveryConfirmationAt: import_zod2.z.string().nullable().optional(),
|
|
397
|
+
lastFailureCode: chatErrorCodeSchema.nullable().optional(),
|
|
398
|
+
supportsStreaming: import_zod2.z.boolean(),
|
|
399
|
+
supportsHistory: import_zod2.z.boolean(),
|
|
400
|
+
supportsEncryption: import_zod2.z.boolean(),
|
|
401
|
+
supportsPayments: import_zod2.z.boolean(),
|
|
402
|
+
supportsAttachments: import_zod2.z.boolean(),
|
|
403
|
+
requiresAuth: import_zod2.z.boolean(),
|
|
404
|
+
operatorActionRequired: import_zod2.z.boolean(),
|
|
405
|
+
issue: import_zod2.z.object({
|
|
406
|
+
code: import_zod2.z.string(),
|
|
407
|
+
message: import_zod2.z.string(),
|
|
408
|
+
details: import_zod2.z.string().optional()
|
|
409
|
+
}).optional()
|
|
410
|
+
});
|
|
295
411
|
var metadataFacetSchema = import_zod2.z.record(
|
|
296
412
|
import_zod2.z.union([
|
|
297
413
|
import_zod2.z.array(jsonValueSchema),
|
|
@@ -491,7 +607,16 @@ var createSessionResponseSchema = import_zod2.z.object({
|
|
|
491
607
|
}),
|
|
492
608
|
history: import_zod2.z.array(chatHistoryEntrySchema).optional().default([]),
|
|
493
609
|
historyTtlSeconds: import_zod2.z.number().nullable().optional(),
|
|
494
|
-
encryption: sessionEncryptionSummarySchema.nullable().optional()
|
|
610
|
+
encryption: sessionEncryptionSummarySchema.nullable().optional(),
|
|
611
|
+
route: chatRouteSummarySchema.optional(),
|
|
612
|
+
transport: import_zod2.z.string().optional(),
|
|
613
|
+
senderUaid: import_zod2.z.string().nullable().optional(),
|
|
614
|
+
visibility: import_zod2.z.enum(["private", "public"]).optional(),
|
|
615
|
+
payment: chatPaymentStateSchema.optional(),
|
|
616
|
+
readiness: chatReadinessResponseSchema.optional(),
|
|
617
|
+
state: chatSessionStateSchema.optional(),
|
|
618
|
+
traceId: import_zod2.z.string().optional(),
|
|
619
|
+
expiresAt: import_zod2.z.string().nullable().optional()
|
|
495
620
|
});
|
|
496
621
|
var sendMessageResponseSchema = import_zod2.z.object({
|
|
497
622
|
sessionId: import_zod2.z.string(),
|
|
@@ -503,7 +628,20 @@ var sendMessageResponseSchema = import_zod2.z.object({
|
|
|
503
628
|
ops: import_zod2.z.array(import_zod2.z.record(jsonValueSchema)).optional(),
|
|
504
629
|
history: import_zod2.z.array(chatHistoryEntrySchema).optional(),
|
|
505
630
|
historyTtlSeconds: import_zod2.z.number().nullable().optional(),
|
|
506
|
-
encrypted: import_zod2.z.boolean().optional()
|
|
631
|
+
encrypted: import_zod2.z.boolean().optional(),
|
|
632
|
+
messageId: import_zod2.z.string().optional(),
|
|
633
|
+
assistantMessageId: import_zod2.z.string().nullable().optional(),
|
|
634
|
+
deliveryState: chatDeliveryStateSchema.optional(),
|
|
635
|
+
replyMode: chatReplyModeSchema.optional(),
|
|
636
|
+
deliveryConfirmation: import_zod2.z.boolean().optional(),
|
|
637
|
+
idempotent: import_zod2.z.boolean().optional(),
|
|
638
|
+
metadata: import_zod2.z.record(jsonValueSchema).optional(),
|
|
639
|
+
errorCode: chatErrorCodeSchema.optional()
|
|
640
|
+
});
|
|
641
|
+
var chatSessionEndResponseSchema = import_zod2.z.object({
|
|
642
|
+
message: import_zod2.z.string(),
|
|
643
|
+
sessionId: import_zod2.z.string(),
|
|
644
|
+
state: chatSessionStateSchema.optional()
|
|
507
645
|
});
|
|
508
646
|
var chatHistorySnapshotResponseSchema = import_zod2.z.object({
|
|
509
647
|
sessionId: import_zod2.z.string(),
|
|
@@ -2977,8 +3115,11 @@ var EncryptedChatManager = class {
|
|
|
2977
3115
|
function createChatApi(client, encryptedManager) {
|
|
2978
3116
|
return {
|
|
2979
3117
|
start: (options) => client.startChat(options),
|
|
3118
|
+
readiness: (payload) => client.checkChatReadiness(payload),
|
|
2980
3119
|
createSession: (payload) => client.createSession(payload),
|
|
2981
3120
|
sendMessage: (payload) => client.sendMessage(payload),
|
|
3121
|
+
retryMessage: (messageId, payload) => client.retryMessage(messageId, payload),
|
|
3122
|
+
cancelSession: (sessionId) => client.cancelSession(sessionId),
|
|
2982
3123
|
endSession: (sessionId) => client.endSession(sessionId),
|
|
2983
3124
|
getHistory: (sessionId, options) => client.fetchHistorySnapshot(sessionId, options),
|
|
2984
3125
|
compactHistory: (payload) => client.compactHistory(payload),
|
|
@@ -2990,6 +3131,30 @@ function createChatApi(client, encryptedManager) {
|
|
|
2990
3131
|
acceptEncryptedSession: (options) => encryptedManager.acceptSession(options)
|
|
2991
3132
|
};
|
|
2992
3133
|
}
|
|
3134
|
+
async function checkChatReadiness(client, payload) {
|
|
3135
|
+
const body = {};
|
|
3136
|
+
const uaid = "uaid" in payload ? payload.uaid?.trim() : void 0;
|
|
3137
|
+
const agentUrl = "agentUrl" in payload ? payload.agentUrl?.trim() : void 0;
|
|
3138
|
+
if (!uaid && !agentUrl) {
|
|
3139
|
+
throw new Error("uaid or agentUrl is required to check chat readiness");
|
|
3140
|
+
}
|
|
3141
|
+
if (uaid) {
|
|
3142
|
+
body.uaid = uaid;
|
|
3143
|
+
}
|
|
3144
|
+
if (agentUrl) {
|
|
3145
|
+
body.agentUrl = agentUrl;
|
|
3146
|
+
}
|
|
3147
|
+
const raw = await client.requestJson("/chat/readiness", {
|
|
3148
|
+
method: "POST",
|
|
3149
|
+
body,
|
|
3150
|
+
headers: { "content-type": "application/json" }
|
|
3151
|
+
});
|
|
3152
|
+
return client.parseWithSchema(
|
|
3153
|
+
raw,
|
|
3154
|
+
chatReadinessResponseSchema,
|
|
3155
|
+
"chat readiness response"
|
|
3156
|
+
);
|
|
3157
|
+
}
|
|
2993
3158
|
async function createSession(client, payload, allowHistoryAutoTopUp = true) {
|
|
2994
3159
|
const body = {};
|
|
2995
3160
|
if ("uaid" in payload && payload.uaid) {
|
|
@@ -3010,6 +3175,9 @@ async function createSession(client, payload, allowHistoryAutoTopUp = true) {
|
|
|
3010
3175
|
if (payload.senderUaid) {
|
|
3011
3176
|
body.senderUaid = payload.senderUaid;
|
|
3012
3177
|
}
|
|
3178
|
+
if (payload.visibility) {
|
|
3179
|
+
body.visibility = payload.visibility;
|
|
3180
|
+
}
|
|
3013
3181
|
try {
|
|
3014
3182
|
const raw = await client.requestJson("/chat/session", {
|
|
3015
3183
|
method: "POST",
|
|
@@ -3244,6 +3412,15 @@ async function sendMessage(client, payload) {
|
|
|
3244
3412
|
if (payload.streaming !== void 0) {
|
|
3245
3413
|
body.streaming = payload.streaming;
|
|
3246
3414
|
}
|
|
3415
|
+
if (payload.idempotencyKey) {
|
|
3416
|
+
body.idempotencyKey = payload.idempotencyKey;
|
|
3417
|
+
}
|
|
3418
|
+
if (payload.senderUaid) {
|
|
3419
|
+
body.senderUaid = payload.senderUaid;
|
|
3420
|
+
}
|
|
3421
|
+
if (payload.transport) {
|
|
3422
|
+
body.transport = payload.transport;
|
|
3423
|
+
}
|
|
3247
3424
|
if (payload.auth) {
|
|
3248
3425
|
body.auth = serialiseAuthConfig(payload.auth);
|
|
3249
3426
|
}
|
|
@@ -3287,9 +3464,130 @@ async function sendMessage(client, payload) {
|
|
|
3287
3464
|
);
|
|
3288
3465
|
}
|
|
3289
3466
|
async function endSession(client, sessionId) {
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3467
|
+
const normalizedSessionId = sessionId?.trim();
|
|
3468
|
+
if (!normalizedSessionId) {
|
|
3469
|
+
throw new Error("sessionId is required to end a chat session");
|
|
3470
|
+
}
|
|
3471
|
+
const response = await client.request(
|
|
3472
|
+
`/chat/session/${encodeURIComponent(normalizedSessionId)}`,
|
|
3473
|
+
{ method: "DELETE" }
|
|
3474
|
+
);
|
|
3475
|
+
if (response.status === 204) {
|
|
3476
|
+
return {
|
|
3477
|
+
message: "Session ended",
|
|
3478
|
+
sessionId: normalizedSessionId,
|
|
3479
|
+
state: "ended"
|
|
3480
|
+
};
|
|
3481
|
+
}
|
|
3482
|
+
const contentType = response.headers?.get("content-type") ?? "";
|
|
3483
|
+
if (!contentType.toLowerCase().includes("json")) {
|
|
3484
|
+
await response.text();
|
|
3485
|
+
return {
|
|
3486
|
+
message: "Session ended",
|
|
3487
|
+
sessionId: normalizedSessionId,
|
|
3488
|
+
state: "ended"
|
|
3489
|
+
};
|
|
3490
|
+
}
|
|
3491
|
+
const responseBody = await response.text();
|
|
3492
|
+
if (responseBody.trim().length === 0) {
|
|
3493
|
+
return {
|
|
3494
|
+
message: "Session ended",
|
|
3495
|
+
sessionId: normalizedSessionId,
|
|
3496
|
+
state: "ended"
|
|
3497
|
+
};
|
|
3498
|
+
}
|
|
3499
|
+
const raw = JSON.parse(responseBody);
|
|
3500
|
+
return client.parseWithSchema(
|
|
3501
|
+
raw,
|
|
3502
|
+
chatSessionEndResponseSchema,
|
|
3503
|
+
"chat session end response"
|
|
3504
|
+
);
|
|
3505
|
+
}
|
|
3506
|
+
async function cancelSession(client, sessionId) {
|
|
3507
|
+
const normalizedSessionId = sessionId?.trim();
|
|
3508
|
+
if (!normalizedSessionId) {
|
|
3509
|
+
throw new Error("sessionId is required to cancel a chat session");
|
|
3510
|
+
}
|
|
3511
|
+
const raw = await client.requestJson(
|
|
3512
|
+
`/chat/session/${encodeURIComponent(normalizedSessionId)}/cancel`,
|
|
3513
|
+
{
|
|
3514
|
+
method: "POST"
|
|
3515
|
+
}
|
|
3516
|
+
);
|
|
3517
|
+
return client.parseWithSchema(
|
|
3518
|
+
raw,
|
|
3519
|
+
chatSessionEndResponseSchema,
|
|
3520
|
+
"chat session cancel response"
|
|
3521
|
+
);
|
|
3522
|
+
}
|
|
3523
|
+
async function retryMessage(client, messageId, payload) {
|
|
3524
|
+
const normalizedMessageId = messageId?.trim();
|
|
3525
|
+
const normalizedSessionId = payload.sessionId?.trim();
|
|
3526
|
+
const normalizedMessage = payload.message?.trim();
|
|
3527
|
+
if (!normalizedMessageId) {
|
|
3528
|
+
throw new Error("messageId is required to retry a message");
|
|
3529
|
+
}
|
|
3530
|
+
if (!normalizedSessionId) {
|
|
3531
|
+
throw new Error("sessionId is required to retry a message");
|
|
3532
|
+
}
|
|
3533
|
+
if (!normalizedMessage) {
|
|
3534
|
+
throw new Error("message is required to retry a message");
|
|
3535
|
+
}
|
|
3536
|
+
const body = {
|
|
3537
|
+
sessionId: normalizedSessionId,
|
|
3538
|
+
message: payload.message
|
|
3539
|
+
};
|
|
3540
|
+
if (payload.streaming !== void 0) {
|
|
3541
|
+
body.streaming = payload.streaming;
|
|
3542
|
+
}
|
|
3543
|
+
if (payload.transport) {
|
|
3544
|
+
body.transport = payload.transport;
|
|
3545
|
+
}
|
|
3546
|
+
const uaid = payload.uaid?.trim();
|
|
3547
|
+
const agentUrl = payload.agentUrl?.trim();
|
|
3548
|
+
const idempotencyKey = payload.idempotencyKey?.trim();
|
|
3549
|
+
const senderUaid = payload.senderUaid?.trim();
|
|
3550
|
+
if (uaid) {
|
|
3551
|
+
body.uaid = uaid;
|
|
3552
|
+
}
|
|
3553
|
+
if (agentUrl) {
|
|
3554
|
+
body.agentUrl = agentUrl;
|
|
3555
|
+
}
|
|
3556
|
+
if (idempotencyKey) {
|
|
3557
|
+
body.idempotencyKey = idempotencyKey;
|
|
3558
|
+
}
|
|
3559
|
+
if (senderUaid) {
|
|
3560
|
+
body.senderUaid = senderUaid;
|
|
3561
|
+
}
|
|
3562
|
+
if (payload.auth) {
|
|
3563
|
+
body.auth = serialiseAuthConfig(payload.auth);
|
|
3564
|
+
}
|
|
3565
|
+
let cipherEnvelope = payload.cipherEnvelope ?? null;
|
|
3566
|
+
if (payload.encryption) {
|
|
3567
|
+
if (!payload.encryption.recipients?.length) {
|
|
3568
|
+
throw new Error("recipients are required for encrypted chat payloads");
|
|
3569
|
+
}
|
|
3570
|
+
cipherEnvelope = client.encryption.encryptCipherEnvelope({
|
|
3571
|
+
...payload.encryption,
|
|
3572
|
+
sessionId: payload.encryption.sessionId ?? normalizedSessionId
|
|
3573
|
+
});
|
|
3574
|
+
}
|
|
3575
|
+
if (cipherEnvelope) {
|
|
3576
|
+
body.cipherEnvelope = toJsonObject(cipherEnvelope);
|
|
3577
|
+
}
|
|
3578
|
+
const raw = await client.requestJson(
|
|
3579
|
+
`/chat/message/${encodeURIComponent(normalizedMessageId)}/retry`,
|
|
3580
|
+
{
|
|
3581
|
+
method: "POST",
|
|
3582
|
+
body,
|
|
3583
|
+
headers: { "content-type": "application/json" }
|
|
3584
|
+
}
|
|
3585
|
+
);
|
|
3586
|
+
return client.parseWithSchema(
|
|
3587
|
+
raw,
|
|
3588
|
+
sendMessageResponseSchema,
|
|
3589
|
+
"chat retry response"
|
|
3590
|
+
);
|
|
3293
3591
|
}
|
|
3294
3592
|
|
|
3295
3593
|
// ../../src/services/registry-broker/client/encryption.ts
|
|
@@ -6980,6 +7278,9 @@ var RegistryBrokerClient = class _RegistryBrokerClient {
|
|
|
6980
7278
|
async createSession(payload, allowHistoryAutoTopUp = true) {
|
|
6981
7279
|
return createSession(this, payload, allowHistoryAutoTopUp);
|
|
6982
7280
|
}
|
|
7281
|
+
async checkChatReadiness(payload) {
|
|
7282
|
+
return checkChatReadiness(this, payload);
|
|
7283
|
+
}
|
|
6983
7284
|
async startChat(options) {
|
|
6984
7285
|
return startChat(this, this.getEncryptedChatManager(), options);
|
|
6985
7286
|
}
|
|
@@ -7005,6 +7306,12 @@ var RegistryBrokerClient = class _RegistryBrokerClient {
|
|
|
7005
7306
|
sendMessage(payload) {
|
|
7006
7307
|
return sendMessage(this, payload);
|
|
7007
7308
|
}
|
|
7309
|
+
retryMessage(messageId, payload) {
|
|
7310
|
+
return retryMessage(this, messageId, payload);
|
|
7311
|
+
}
|
|
7312
|
+
cancelSession(sessionId) {
|
|
7313
|
+
return cancelSession(this, sessionId);
|
|
7314
|
+
}
|
|
7008
7315
|
endSession(sessionId) {
|
|
7009
7316
|
return endSession(this, sessionId);
|
|
7010
7317
|
}
|