@hashgraphonline/standards-sdk 0.1.180 → 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/browser/services/registry-broker/client/base-client.d.ts +8 -2
- package/dist/browser/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/browser/services/registry-broker/client/chat.d.ts +9 -3
- package/dist/browser/services/registry-broker/client/chat.d.ts.map +1 -1
- package/dist/browser/services/registry-broker/client/guard.d.ts.map +1 -1
- package/dist/browser/services/registry-broker/schemas.d.ts +471 -108
- package/dist/browser/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/browser/services/registry-broker/types.d.ts +25 -1
- package/dist/browser/services/registry-broker/types.d.ts.map +1 -1
- package/dist/browser/standards-sdk.browser.js +141 -3
- package/dist/browser/standards-sdk.browser.js.map +1 -1
- package/dist/browser-root/services/registry-broker/client/base-client.d.ts +8 -2
- package/dist/browser-root/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/browser-root/services/registry-broker/client/chat.d.ts +9 -3
- package/dist/browser-root/services/registry-broker/client/chat.d.ts.map +1 -1
- package/dist/browser-root/services/registry-broker/client/guard.d.ts.map +1 -1
- package/dist/browser-root/services/registry-broker/schemas.d.ts +471 -108
- package/dist/browser-root/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/browser-root/services/registry-broker/types.d.ts +25 -1
- package/dist/browser-root/services/registry-broker/types.d.ts.map +1 -1
- package/dist/browser-root/standards-sdk.root-browser.js +653 -110
- package/dist/browser-root/standards-sdk.root-browser.js.map +1 -1
- package/dist/cjs/services/registry-broker/client/base-client.d.ts +8 -2
- package/dist/cjs/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client/chat.d.ts +9 -3
- package/dist/cjs/services/registry-broker/client/chat.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client/guard.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/schemas.d.ts +587 -224
- package/dist/cjs/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/types.d.ts +25 -1
- package/dist/cjs/services/registry-broker/types.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +1 -1
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/services/registry-broker/client/base-client.d.ts +8 -2
- package/dist/es/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client/chat.d.ts +9 -3
- package/dist/es/services/registry-broker/client/chat.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client/guard.d.ts.map +1 -1
- package/dist/es/services/registry-broker/schemas.d.ts +587 -224
- package/dist/es/services/registry-broker/schemas.d.ts.map +1 -1
- package/dist/es/services/registry-broker/types.d.ts +25 -1
- package/dist/es/services/registry-broker/types.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +10 -7
- package/dist/es/standards-sdk.es.js.map +1 -1
- package/dist/es/standards-sdk.es104.js +1 -1
- package/dist/es/standards-sdk.es106.js +1 -1
- package/dist/es/standards-sdk.es108.js +1 -1
- package/dist/es/standards-sdk.es11.js +1 -1
- package/dist/es/standards-sdk.es110.js +1 -1
- package/dist/es/standards-sdk.es116.js +2 -2
- package/dist/es/standards-sdk.es12.js +1 -1
- package/dist/es/standards-sdk.es121.js +1 -1
- package/dist/es/standards-sdk.es127.js +2 -2
- package/dist/es/standards-sdk.es128.js +5 -5
- package/dist/es/standards-sdk.es138.js +1 -1
- package/dist/es/standards-sdk.es139.js +1 -1
- package/dist/es/standards-sdk.es140.js +5 -5
- package/dist/es/standards-sdk.es142.js +3 -3
- package/dist/es/standards-sdk.es143.js +1 -1
- package/dist/es/standards-sdk.es145.js +53 -15
- package/dist/es/standards-sdk.es145.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +3 -3
- package/dist/es/standards-sdk.es148.js +4 -81
- package/dist/es/standards-sdk.es148.js.map +1 -1
- package/dist/es/standards-sdk.es149.js +71 -77
- package/dist/es/standards-sdk.es149.js.map +1 -1
- package/dist/es/standards-sdk.es150.js +80 -53
- package/dist/es/standards-sdk.es150.js.map +1 -1
- package/dist/es/standards-sdk.es151.js +53 -152
- package/dist/es/standards-sdk.es151.js.map +1 -1
- package/dist/es/standards-sdk.es152.js +159 -7
- package/dist/es/standards-sdk.es152.js.map +1 -1
- package/dist/es/standards-sdk.es153.js +7 -86
- package/dist/es/standards-sdk.es153.js.map +1 -1
- package/dist/es/standards-sdk.es154.js +64 -43
- package/dist/es/standards-sdk.es154.js.map +1 -1
- package/dist/es/standards-sdk.es155.js +65 -30
- package/dist/es/standards-sdk.es155.js.map +1 -1
- package/dist/es/standards-sdk.es156.js +30 -34
- package/dist/es/standards-sdk.es156.js.map +1 -1
- package/dist/es/standards-sdk.es157.js +34 -48
- package/dist/es/standards-sdk.es157.js.map +1 -1
- package/dist/es/standards-sdk.es158.js +48 -138
- package/dist/es/standards-sdk.es158.js.map +1 -1
- package/dist/es/standards-sdk.es159.js +133 -37
- package/dist/es/standards-sdk.es159.js.map +1 -1
- package/dist/es/standards-sdk.es16.js +2 -2
- package/dist/es/standards-sdk.es160.js +42 -2352
- package/dist/es/standards-sdk.es160.js.map +1 -1
- package/dist/es/standards-sdk.es161.js +2488 -12476
- package/dist/es/standards-sdk.es161.js.map +1 -1
- package/dist/es/standards-sdk.es162.js +12425 -615
- package/dist/es/standards-sdk.es162.js.map +1 -1
- package/dist/es/standards-sdk.es163.js +15 -54
- package/dist/es/standards-sdk.es163.js.map +1 -1
- package/dist/es/standards-sdk.es164.js +47 -102
- package/dist/es/standards-sdk.es164.js.map +1 -1
- package/dist/es/standards-sdk.es165.js +94 -64
- package/dist/es/standards-sdk.es165.js.map +1 -1
- package/dist/es/standards-sdk.es166.js +61 -180
- package/dist/es/standards-sdk.es166.js.map +1 -1
- package/dist/es/standards-sdk.es167.js +197 -14
- package/dist/es/standards-sdk.es167.js.map +1 -1
- package/dist/es/standards-sdk.es168.js +165 -66
- package/dist/es/standards-sdk.es168.js.map +1 -1
- package/dist/es/standards-sdk.es169.js +289 -139
- package/dist/es/standards-sdk.es169.js.map +1 -1
- package/dist/es/standards-sdk.es170.js +298 -274
- package/dist/es/standards-sdk.es170.js.map +1 -1
- package/dist/es/standards-sdk.es171.js +369 -262
- package/dist/es/standards-sdk.es171.js.map +1 -1
- package/dist/es/standards-sdk.es172.js +194 -316
- package/dist/es/standards-sdk.es172.js.map +1 -1
- package/dist/es/standards-sdk.es173.js +64 -319
- package/dist/es/standards-sdk.es173.js.map +1 -1
- package/dist/es/standards-sdk.es174.js +664 -68
- package/dist/es/standards-sdk.es174.js.map +1 -1
- package/dist/es/standards-sdk.es175.js +60 -126
- package/dist/es/standards-sdk.es175.js.map +1 -1
- package/dist/es/standards-sdk.es176.js +111 -303
- package/dist/es/standards-sdk.es176.js.map +1 -1
- package/dist/es/standards-sdk.es177.js +457 -222
- package/dist/es/standards-sdk.es177.js.map +1 -1
- package/dist/es/standards-sdk.es178.js +239 -176
- package/dist/es/standards-sdk.es178.js.map +1 -1
- package/dist/es/standards-sdk.es179.js +178 -101
- package/dist/es/standards-sdk.es179.js.map +1 -1
- package/dist/es/standards-sdk.es18.js +5 -5
- package/dist/es/standards-sdk.es180.js +75 -108
- package/dist/es/standards-sdk.es180.js.map +1 -1
- package/dist/es/standards-sdk.es181.js +116 -148
- package/dist/es/standards-sdk.es181.js.map +1 -1
- package/dist/es/standards-sdk.es182.js +143 -439
- package/dist/es/standards-sdk.es182.js.map +1 -1
- package/dist/es/standards-sdk.es183.js +661 -162
- package/dist/es/standards-sdk.es183.js.map +1 -1
- package/dist/es/standards-sdk.es184.js +156 -206
- package/dist/es/standards-sdk.es184.js.map +1 -1
- package/dist/es/standards-sdk.es185.js +219 -223
- package/dist/es/standards-sdk.es185.js.map +1 -1
- package/dist/es/standards-sdk.es186.js +242 -0
- package/dist/es/standards-sdk.es186.js.map +1 -0
- package/dist/es/standards-sdk.es19.js +3 -3
- package/dist/es/standards-sdk.es22.js +1 -1
- package/dist/es/standards-sdk.es27.js +5 -5
- package/dist/es/standards-sdk.es30.js +1 -1
- package/dist/es/standards-sdk.es31.js +1 -1
- package/dist/es/standards-sdk.es35.js +2 -2
- package/dist/es/standards-sdk.es36.js +3 -3
- package/dist/es/standards-sdk.es37.js +1 -1
- package/dist/es/standards-sdk.es4.js +1 -1
- package/dist/es/standards-sdk.es53.js +1 -1
- package/dist/es/standards-sdk.es56.js +1 -1
- package/dist/es/standards-sdk.es59.js +1 -1
- package/dist/es/standards-sdk.es60.js +1 -1
- package/dist/es/standards-sdk.es62.js +1 -1
- package/dist/es/standards-sdk.es63.js +2 -2
- package/dist/es/standards-sdk.es64.js +1 -1
- package/dist/es/standards-sdk.es65.js +1 -1
- package/dist/es/standards-sdk.es66.js +1 -1
- package/dist/es/standards-sdk.es67.js +3 -3
- package/dist/es/standards-sdk.es69.js +1 -1
- package/dist/es/standards-sdk.es7.js +1 -1
- package/dist/es/standards-sdk.es71.js +1 -1
- package/dist/es/standards-sdk.es72.js +2 -2
- package/dist/es/standards-sdk.es75.js +3 -3
- package/dist/es/standards-sdk.es76.js +1 -1
- package/dist/es/standards-sdk.es78.js +1 -1
- package/dist/es/standards-sdk.es83.js +1 -1
- package/dist/es/standards-sdk.es84.js +2 -2
- package/dist/es/standards-sdk.es85.js +1 -1
- package/dist/es/standards-sdk.es88.js +1 -1
- package/dist/es/standards-sdk.es90.js +1 -1
- package/dist/es/standards-sdk.es94.js +3 -3
- package/dist/es/standards-sdk.es98.js +1 -1
- package/dist/es/standards-sdk.es99.js +1 -1
- package/package.json +1 -1
|
@@ -6151,12 +6151,128 @@ const sessionEncryptionSummarySchema = objectType({
|
|
|
6151
6151
|
});
|
|
6152
6152
|
const chatHistoryEntrySchema = objectType({
|
|
6153
6153
|
messageId: stringType(),
|
|
6154
|
-
role: enumType([
|
|
6154
|
+
role: enumType([
|
|
6155
|
+
"user",
|
|
6156
|
+
"agent",
|
|
6157
|
+
"system",
|
|
6158
|
+
"tool",
|
|
6159
|
+
"payment",
|
|
6160
|
+
"delivery",
|
|
6161
|
+
"error"
|
|
6162
|
+
]),
|
|
6155
6163
|
content: stringType(),
|
|
6156
6164
|
timestamp: stringType(),
|
|
6157
6165
|
cipherEnvelope: cipherEnvelopeSchema.optional(),
|
|
6158
6166
|
metadata: recordType(jsonValueSchema).optional()
|
|
6159
6167
|
});
|
|
6168
|
+
const chatDeliveryStateSchema = enumType([
|
|
6169
|
+
"draft",
|
|
6170
|
+
"queued",
|
|
6171
|
+
"persisted",
|
|
6172
|
+
"delivered",
|
|
6173
|
+
"streaming",
|
|
6174
|
+
"responded",
|
|
6175
|
+
"failed",
|
|
6176
|
+
"timeout",
|
|
6177
|
+
"cancelled"
|
|
6178
|
+
]);
|
|
6179
|
+
const chatReadinessStatusSchema = enumType([
|
|
6180
|
+
"responsive",
|
|
6181
|
+
"delivery_only",
|
|
6182
|
+
"degraded",
|
|
6183
|
+
"blocked",
|
|
6184
|
+
"unknown"
|
|
6185
|
+
]);
|
|
6186
|
+
const chatReplyModeSchema = enumType([
|
|
6187
|
+
"direct",
|
|
6188
|
+
"stream",
|
|
6189
|
+
"poll",
|
|
6190
|
+
"delivery_only",
|
|
6191
|
+
"none"
|
|
6192
|
+
]);
|
|
6193
|
+
const chatRouteTypeSchema = enumType([
|
|
6194
|
+
"a2a",
|
|
6195
|
+
"hcs-10",
|
|
6196
|
+
"mcp",
|
|
6197
|
+
"openrouter",
|
|
6198
|
+
"acp",
|
|
6199
|
+
"xmtp",
|
|
6200
|
+
"moltbook",
|
|
6201
|
+
"agentverse",
|
|
6202
|
+
"nanda",
|
|
6203
|
+
"http",
|
|
6204
|
+
"erc-8004",
|
|
6205
|
+
"x402",
|
|
6206
|
+
"unknown"
|
|
6207
|
+
]);
|
|
6208
|
+
const chatSessionStateSchema = enumType([
|
|
6209
|
+
"connecting",
|
|
6210
|
+
"ready",
|
|
6211
|
+
"blocked",
|
|
6212
|
+
"ended",
|
|
6213
|
+
"expired"
|
|
6214
|
+
]);
|
|
6215
|
+
const chatErrorCodeSchema = enumType([
|
|
6216
|
+
"AUTH_REQUIRED",
|
|
6217
|
+
"CREDITS_REQUIRED",
|
|
6218
|
+
"PAYMENT_REQUIRED",
|
|
6219
|
+
"AGENT_UNRESPONSIVE",
|
|
6220
|
+
"ROUTE_UNAVAILABLE",
|
|
6221
|
+
"PROTOCOL_UNSUPPORTED",
|
|
6222
|
+
"BROKER_NOT_EXECUTABLE",
|
|
6223
|
+
"NETWORK_TIMEOUT",
|
|
6224
|
+
"STREAM_STALLED",
|
|
6225
|
+
"HISTORY_UNAVAILABLE",
|
|
6226
|
+
"ENCRYPTION_REQUIRED",
|
|
6227
|
+
"RATE_LIMITED",
|
|
6228
|
+
"VALIDATION_ERROR",
|
|
6229
|
+
"UNKNOWN_ERROR"
|
|
6230
|
+
]);
|
|
6231
|
+
const chatRouteSummarySchema = objectType({
|
|
6232
|
+
type: chatRouteTypeSchema,
|
|
6233
|
+
replyMode: chatReplyModeSchema,
|
|
6234
|
+
transport: stringType(),
|
|
6235
|
+
endpoint: stringType().optional()
|
|
6236
|
+
});
|
|
6237
|
+
const chatPaymentStateSchema = objectType({
|
|
6238
|
+
required: booleanType(),
|
|
6239
|
+
provider: enumType(["credits", "x402", "acp", "openrouter"]).optional(),
|
|
6240
|
+
status: enumType([
|
|
6241
|
+
"not_required",
|
|
6242
|
+
"preflight",
|
|
6243
|
+
"required",
|
|
6244
|
+
"approved",
|
|
6245
|
+
"paid",
|
|
6246
|
+
"failed"
|
|
6247
|
+
]),
|
|
6248
|
+
estimatedCredits: numberType().nullable().optional(),
|
|
6249
|
+
estimatedUsd: numberType().nullable().optional()
|
|
6250
|
+
});
|
|
6251
|
+
const chatReadinessResponseSchema = objectType({
|
|
6252
|
+
status: chatReadinessStatusSchema,
|
|
6253
|
+
routeType: chatRouteTypeSchema,
|
|
6254
|
+
replyMode: chatReplyModeSchema,
|
|
6255
|
+
transport: stringType(),
|
|
6256
|
+
endpoint: stringType().optional(),
|
|
6257
|
+
checkedAt: stringType(),
|
|
6258
|
+
cachedUntil: stringType(),
|
|
6259
|
+
latencyMs: numberType().nullable().optional(),
|
|
6260
|
+
lastSuccessfulReplyAt: stringType().nullable().optional(),
|
|
6261
|
+
lastDeliveryConfirmationAt: stringType().nullable().optional(),
|
|
6262
|
+
lastFailureCode: chatErrorCodeSchema.nullable().optional(),
|
|
6263
|
+
supportsStreaming: booleanType(),
|
|
6264
|
+
supportsHistory: booleanType(),
|
|
6265
|
+
supportsEncryption: booleanType(),
|
|
6266
|
+
supportsPayments: booleanType(),
|
|
6267
|
+
supportsAttachments: booleanType(),
|
|
6268
|
+
requiresAuth: booleanType(),
|
|
6269
|
+
operatorActionRequired: booleanType(),
|
|
6270
|
+
issue: objectType({
|
|
6271
|
+
code: stringType(),
|
|
6272
|
+
message: stringType(),
|
|
6273
|
+
details: stringType().optional()
|
|
6274
|
+
}).optional()
|
|
6275
|
+
});
|
|
6160
6276
|
const metadataFacetSchema = recordType(
|
|
6161
6277
|
unionType([
|
|
6162
6278
|
arrayType(jsonValueSchema),
|
|
@@ -6356,7 +6472,16 @@ const createSessionResponseSchema = objectType({
|
|
|
6356
6472
|
}),
|
|
6357
6473
|
history: arrayType(chatHistoryEntrySchema).optional().default([]),
|
|
6358
6474
|
historyTtlSeconds: numberType().nullable().optional(),
|
|
6359
|
-
encryption: sessionEncryptionSummarySchema.nullable().optional()
|
|
6475
|
+
encryption: sessionEncryptionSummarySchema.nullable().optional(),
|
|
6476
|
+
route: chatRouteSummarySchema.optional(),
|
|
6477
|
+
transport: stringType().optional(),
|
|
6478
|
+
senderUaid: stringType().nullable().optional(),
|
|
6479
|
+
visibility: enumType(["private", "public"]).optional(),
|
|
6480
|
+
payment: chatPaymentStateSchema.optional(),
|
|
6481
|
+
readiness: chatReadinessResponseSchema.optional(),
|
|
6482
|
+
state: chatSessionStateSchema.optional(),
|
|
6483
|
+
traceId: stringType().optional(),
|
|
6484
|
+
expiresAt: stringType().nullable().optional()
|
|
6360
6485
|
});
|
|
6361
6486
|
const sendMessageResponseSchema = objectType({
|
|
6362
6487
|
sessionId: stringType(),
|
|
@@ -6368,7 +6493,20 @@ const sendMessageResponseSchema = objectType({
|
|
|
6368
6493
|
ops: arrayType(recordType(jsonValueSchema)).optional(),
|
|
6369
6494
|
history: arrayType(chatHistoryEntrySchema).optional(),
|
|
6370
6495
|
historyTtlSeconds: numberType().nullable().optional(),
|
|
6371
|
-
encrypted: booleanType().optional()
|
|
6496
|
+
encrypted: booleanType().optional(),
|
|
6497
|
+
messageId: stringType().optional(),
|
|
6498
|
+
assistantMessageId: stringType().nullable().optional(),
|
|
6499
|
+
deliveryState: chatDeliveryStateSchema.optional(),
|
|
6500
|
+
replyMode: chatReplyModeSchema.optional(),
|
|
6501
|
+
deliveryConfirmation: booleanType().optional(),
|
|
6502
|
+
idempotent: booleanType().optional(),
|
|
6503
|
+
metadata: recordType(jsonValueSchema).optional(),
|
|
6504
|
+
errorCode: chatErrorCodeSchema.optional()
|
|
6505
|
+
});
|
|
6506
|
+
const chatSessionEndResponseSchema = objectType({
|
|
6507
|
+
message: stringType(),
|
|
6508
|
+
sessionId: stringType(),
|
|
6509
|
+
state: chatSessionStateSchema.optional()
|
|
6372
6510
|
});
|
|
6373
6511
|
const chatHistorySnapshotResponseSchema = objectType({
|
|
6374
6512
|
sessionId: stringType(),
|
|
@@ -8833,8 +8971,11 @@ class EncryptedChatManager {
|
|
|
8833
8971
|
function createChatApi(client, encryptedManager) {
|
|
8834
8972
|
return {
|
|
8835
8973
|
start: (options) => client.startChat(options),
|
|
8974
|
+
readiness: (payload) => client.checkChatReadiness(payload),
|
|
8836
8975
|
createSession: (payload) => client.createSession(payload),
|
|
8837
8976
|
sendMessage: (payload) => client.sendMessage(payload),
|
|
8977
|
+
retryMessage: (messageId, payload) => client.retryMessage(messageId, payload),
|
|
8978
|
+
cancelSession: (sessionId) => client.cancelSession(sessionId),
|
|
8838
8979
|
endSession: (sessionId) => client.endSession(sessionId),
|
|
8839
8980
|
getHistory: (sessionId, options) => client.fetchHistorySnapshot(sessionId, options),
|
|
8840
8981
|
compactHistory: (payload) => client.compactHistory(payload),
|
|
@@ -8846,6 +8987,30 @@ function createChatApi(client, encryptedManager) {
|
|
|
8846
8987
|
acceptEncryptedSession: (options) => encryptedManager.acceptSession(options)
|
|
8847
8988
|
};
|
|
8848
8989
|
}
|
|
8990
|
+
async function checkChatReadiness(client, payload) {
|
|
8991
|
+
const body = {};
|
|
8992
|
+
const uaid = "uaid" in payload ? payload.uaid?.trim() : void 0;
|
|
8993
|
+
const agentUrl = "agentUrl" in payload ? payload.agentUrl?.trim() : void 0;
|
|
8994
|
+
if (!uaid && !agentUrl) {
|
|
8995
|
+
throw new Error("uaid or agentUrl is required to check chat readiness");
|
|
8996
|
+
}
|
|
8997
|
+
if (uaid) {
|
|
8998
|
+
body.uaid = uaid;
|
|
8999
|
+
}
|
|
9000
|
+
if (agentUrl) {
|
|
9001
|
+
body.agentUrl = agentUrl;
|
|
9002
|
+
}
|
|
9003
|
+
const raw = await client.requestJson("/chat/readiness", {
|
|
9004
|
+
method: "POST",
|
|
9005
|
+
body,
|
|
9006
|
+
headers: { "content-type": "application/json" }
|
|
9007
|
+
});
|
|
9008
|
+
return client.parseWithSchema(
|
|
9009
|
+
raw,
|
|
9010
|
+
chatReadinessResponseSchema,
|
|
9011
|
+
"chat readiness response"
|
|
9012
|
+
);
|
|
9013
|
+
}
|
|
8849
9014
|
async function createSession(client, payload, allowHistoryAutoTopUp = true) {
|
|
8850
9015
|
const body = {};
|
|
8851
9016
|
if ("uaid" in payload && payload.uaid) {
|
|
@@ -8866,6 +9031,9 @@ async function createSession(client, payload, allowHistoryAutoTopUp = true) {
|
|
|
8866
9031
|
if (payload.senderUaid) {
|
|
8867
9032
|
body.senderUaid = payload.senderUaid;
|
|
8868
9033
|
}
|
|
9034
|
+
if (payload.visibility) {
|
|
9035
|
+
body.visibility = payload.visibility;
|
|
9036
|
+
}
|
|
8869
9037
|
try {
|
|
8870
9038
|
const raw = await client.requestJson("/chat/session", {
|
|
8871
9039
|
method: "POST",
|
|
@@ -9100,6 +9268,15 @@ async function sendMessage(client, payload) {
|
|
|
9100
9268
|
if (payload.streaming !== void 0) {
|
|
9101
9269
|
body.streaming = payload.streaming;
|
|
9102
9270
|
}
|
|
9271
|
+
if (payload.idempotencyKey) {
|
|
9272
|
+
body.idempotencyKey = payload.idempotencyKey;
|
|
9273
|
+
}
|
|
9274
|
+
if (payload.senderUaid) {
|
|
9275
|
+
body.senderUaid = payload.senderUaid;
|
|
9276
|
+
}
|
|
9277
|
+
if (payload.transport) {
|
|
9278
|
+
body.transport = payload.transport;
|
|
9279
|
+
}
|
|
9103
9280
|
if (payload.auth) {
|
|
9104
9281
|
body.auth = serialiseAuthConfig(payload.auth);
|
|
9105
9282
|
}
|
|
@@ -9143,9 +9320,130 @@ async function sendMessage(client, payload) {
|
|
|
9143
9320
|
);
|
|
9144
9321
|
}
|
|
9145
9322
|
async function endSession(client, sessionId) {
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
|
|
9323
|
+
const normalizedSessionId = sessionId?.trim();
|
|
9324
|
+
if (!normalizedSessionId) {
|
|
9325
|
+
throw new Error("sessionId is required to end a chat session");
|
|
9326
|
+
}
|
|
9327
|
+
const response = await client.request(
|
|
9328
|
+
`/chat/session/${encodeURIComponent(normalizedSessionId)}`,
|
|
9329
|
+
{ method: "DELETE" }
|
|
9330
|
+
);
|
|
9331
|
+
if (response.status === 204) {
|
|
9332
|
+
return {
|
|
9333
|
+
message: "Session ended",
|
|
9334
|
+
sessionId: normalizedSessionId,
|
|
9335
|
+
state: "ended"
|
|
9336
|
+
};
|
|
9337
|
+
}
|
|
9338
|
+
const contentType = response.headers?.get("content-type") ?? "";
|
|
9339
|
+
if (!contentType.toLowerCase().includes("json")) {
|
|
9340
|
+
await response.text();
|
|
9341
|
+
return {
|
|
9342
|
+
message: "Session ended",
|
|
9343
|
+
sessionId: normalizedSessionId,
|
|
9344
|
+
state: "ended"
|
|
9345
|
+
};
|
|
9346
|
+
}
|
|
9347
|
+
const responseBody = await response.text();
|
|
9348
|
+
if (responseBody.trim().length === 0) {
|
|
9349
|
+
return {
|
|
9350
|
+
message: "Session ended",
|
|
9351
|
+
sessionId: normalizedSessionId,
|
|
9352
|
+
state: "ended"
|
|
9353
|
+
};
|
|
9354
|
+
}
|
|
9355
|
+
const raw = JSON.parse(responseBody);
|
|
9356
|
+
return client.parseWithSchema(
|
|
9357
|
+
raw,
|
|
9358
|
+
chatSessionEndResponseSchema,
|
|
9359
|
+
"chat session end response"
|
|
9360
|
+
);
|
|
9361
|
+
}
|
|
9362
|
+
async function cancelSession(client, sessionId) {
|
|
9363
|
+
const normalizedSessionId = sessionId?.trim();
|
|
9364
|
+
if (!normalizedSessionId) {
|
|
9365
|
+
throw new Error("sessionId is required to cancel a chat session");
|
|
9366
|
+
}
|
|
9367
|
+
const raw = await client.requestJson(
|
|
9368
|
+
`/chat/session/${encodeURIComponent(normalizedSessionId)}/cancel`,
|
|
9369
|
+
{
|
|
9370
|
+
method: "POST"
|
|
9371
|
+
}
|
|
9372
|
+
);
|
|
9373
|
+
return client.parseWithSchema(
|
|
9374
|
+
raw,
|
|
9375
|
+
chatSessionEndResponseSchema,
|
|
9376
|
+
"chat session cancel response"
|
|
9377
|
+
);
|
|
9378
|
+
}
|
|
9379
|
+
async function retryMessage(client, messageId, payload) {
|
|
9380
|
+
const normalizedMessageId = messageId?.trim();
|
|
9381
|
+
const normalizedSessionId = payload.sessionId?.trim();
|
|
9382
|
+
const normalizedMessage = payload.message?.trim();
|
|
9383
|
+
if (!normalizedMessageId) {
|
|
9384
|
+
throw new Error("messageId is required to retry a message");
|
|
9385
|
+
}
|
|
9386
|
+
if (!normalizedSessionId) {
|
|
9387
|
+
throw new Error("sessionId is required to retry a message");
|
|
9388
|
+
}
|
|
9389
|
+
if (!normalizedMessage) {
|
|
9390
|
+
throw new Error("message is required to retry a message");
|
|
9391
|
+
}
|
|
9392
|
+
const body = {
|
|
9393
|
+
sessionId: normalizedSessionId,
|
|
9394
|
+
message: payload.message
|
|
9395
|
+
};
|
|
9396
|
+
if (payload.streaming !== void 0) {
|
|
9397
|
+
body.streaming = payload.streaming;
|
|
9398
|
+
}
|
|
9399
|
+
if (payload.transport) {
|
|
9400
|
+
body.transport = payload.transport;
|
|
9401
|
+
}
|
|
9402
|
+
const uaid = payload.uaid?.trim();
|
|
9403
|
+
const agentUrl = payload.agentUrl?.trim();
|
|
9404
|
+
const idempotencyKey = payload.idempotencyKey?.trim();
|
|
9405
|
+
const senderUaid = payload.senderUaid?.trim();
|
|
9406
|
+
if (uaid) {
|
|
9407
|
+
body.uaid = uaid;
|
|
9408
|
+
}
|
|
9409
|
+
if (agentUrl) {
|
|
9410
|
+
body.agentUrl = agentUrl;
|
|
9411
|
+
}
|
|
9412
|
+
if (idempotencyKey) {
|
|
9413
|
+
body.idempotencyKey = idempotencyKey;
|
|
9414
|
+
}
|
|
9415
|
+
if (senderUaid) {
|
|
9416
|
+
body.senderUaid = senderUaid;
|
|
9417
|
+
}
|
|
9418
|
+
if (payload.auth) {
|
|
9419
|
+
body.auth = serialiseAuthConfig(payload.auth);
|
|
9420
|
+
}
|
|
9421
|
+
let cipherEnvelope = payload.cipherEnvelope ?? null;
|
|
9422
|
+
if (payload.encryption) {
|
|
9423
|
+
if (!payload.encryption.recipients?.length) {
|
|
9424
|
+
throw new Error("recipients are required for encrypted chat payloads");
|
|
9425
|
+
}
|
|
9426
|
+
cipherEnvelope = client.encryption.encryptCipherEnvelope({
|
|
9427
|
+
...payload.encryption,
|
|
9428
|
+
sessionId: payload.encryption.sessionId ?? normalizedSessionId
|
|
9429
|
+
});
|
|
9430
|
+
}
|
|
9431
|
+
if (cipherEnvelope) {
|
|
9432
|
+
body.cipherEnvelope = toJsonObject(cipherEnvelope);
|
|
9433
|
+
}
|
|
9434
|
+
const raw = await client.requestJson(
|
|
9435
|
+
`/chat/message/${encodeURIComponent(normalizedMessageId)}/retry`,
|
|
9436
|
+
{
|
|
9437
|
+
method: "POST",
|
|
9438
|
+
body,
|
|
9439
|
+
headers: { "content-type": "application/json" }
|
|
9440
|
+
}
|
|
9441
|
+
);
|
|
9442
|
+
return client.parseWithSchema(
|
|
9443
|
+
raw,
|
|
9444
|
+
sendMessageResponseSchema,
|
|
9445
|
+
"chat retry response"
|
|
9446
|
+
);
|
|
9149
9447
|
}
|
|
9150
9448
|
const isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined";
|
|
9151
9449
|
let nodeRequire;
|
|
@@ -10127,10 +10425,98 @@ async function registerOwnedMoltbookAgent(client, uaid, request) {
|
|
|
10127
10425
|
"moltbook owner registration update response"
|
|
10128
10426
|
);
|
|
10129
10427
|
}
|
|
10428
|
+
function isStatusError(error) {
|
|
10429
|
+
if (error instanceof RegistryBrokerError) {
|
|
10430
|
+
return true;
|
|
10431
|
+
}
|
|
10432
|
+
if (typeof error !== "object" || error === null || !("status" in error)) {
|
|
10433
|
+
return false;
|
|
10434
|
+
}
|
|
10435
|
+
return typeof Reflect.get(error, "status") === "number";
|
|
10436
|
+
}
|
|
10437
|
+
function toPortalCanonicalGuardPath(path) {
|
|
10438
|
+
const segments = path.split("/");
|
|
10439
|
+
const findPatternStart = (size2, matcher) => {
|
|
10440
|
+
for (let startIndex = segments.length - size2; startIndex >= 0; startIndex -= 1) {
|
|
10441
|
+
if (matcher(startIndex)) {
|
|
10442
|
+
return startIndex;
|
|
10443
|
+
}
|
|
10444
|
+
}
|
|
10445
|
+
return -1;
|
|
10446
|
+
};
|
|
10447
|
+
const replaceAt = (startIndex, consumed) => [
|
|
10448
|
+
...segments.slice(0, startIndex),
|
|
10449
|
+
"api",
|
|
10450
|
+
"guard",
|
|
10451
|
+
...segments.slice(startIndex + consumed)
|
|
10452
|
+
].join("/");
|
|
10453
|
+
const registryStart = findPatternStart(
|
|
10454
|
+
4,
|
|
10455
|
+
(startIndex) => segments[startIndex] === "registry" && segments[startIndex + 1] === "api" && /^v\d+$/.test(segments[startIndex + 2] ?? "") && segments[startIndex + 3] === "guard"
|
|
10456
|
+
);
|
|
10457
|
+
if (registryStart >= 0) {
|
|
10458
|
+
return replaceAt(registryStart, 4);
|
|
10459
|
+
}
|
|
10460
|
+
const apiVersionStart = findPatternStart(
|
|
10461
|
+
3,
|
|
10462
|
+
(startIndex) => segments[startIndex] === "api" && /^v\d+$/.test(segments[startIndex + 1] ?? "") && segments[startIndex + 2] === "guard"
|
|
10463
|
+
);
|
|
10464
|
+
if (apiVersionStart >= 0) {
|
|
10465
|
+
return replaceAt(apiVersionStart, 3);
|
|
10466
|
+
}
|
|
10467
|
+
for (let index2 = segments.length - 1; index2 >= 0; index2 -= 1) {
|
|
10468
|
+
if (segments[index2] === "guard" && segments[index2 - 1] !== "api") {
|
|
10469
|
+
return [
|
|
10470
|
+
...segments.slice(0, index2),
|
|
10471
|
+
"api",
|
|
10472
|
+
"guard",
|
|
10473
|
+
...segments.slice(index2 + 1)
|
|
10474
|
+
].join("/");
|
|
10475
|
+
}
|
|
10476
|
+
}
|
|
10477
|
+
return path;
|
|
10478
|
+
}
|
|
10479
|
+
function buildPortalCanonicalGuardUrl(baseUrl, path) {
|
|
10480
|
+
const target = new URL(path, "https://guard.local");
|
|
10481
|
+
const normalizedBasePath = (() => {
|
|
10482
|
+
try {
|
|
10483
|
+
const base = new URL(baseUrl);
|
|
10484
|
+
return base.pathname.replace(/\/+$/, "");
|
|
10485
|
+
} catch {
|
|
10486
|
+
return baseUrl.replace(/\/+$/, "");
|
|
10487
|
+
}
|
|
10488
|
+
})();
|
|
10489
|
+
const requestedPath = `${normalizedBasePath}${target.pathname}`;
|
|
10490
|
+
const canonicalPath = toPortalCanonicalGuardPath(requestedPath);
|
|
10491
|
+
const canonicalRelativePath = `${canonicalPath}${target.search}`;
|
|
10492
|
+
try {
|
|
10493
|
+
const base = new URL(baseUrl);
|
|
10494
|
+
return `${base.origin}${canonicalRelativePath}`;
|
|
10495
|
+
} catch {
|
|
10496
|
+
return canonicalRelativePath;
|
|
10497
|
+
}
|
|
10498
|
+
}
|
|
10499
|
+
async function requestPortalFirstJson(client, path, init) {
|
|
10500
|
+
try {
|
|
10501
|
+
return await client.requestJson(path, init);
|
|
10502
|
+
} catch (error) {
|
|
10503
|
+
if (isStatusError(error) && (error.status === 404 || error.status === 501)) {
|
|
10504
|
+
return client.requestAbsoluteJson(
|
|
10505
|
+
buildPortalCanonicalGuardUrl(client.baseUrl, path),
|
|
10506
|
+
init
|
|
10507
|
+
);
|
|
10508
|
+
}
|
|
10509
|
+
throw error;
|
|
10510
|
+
}
|
|
10511
|
+
}
|
|
10130
10512
|
async function getGuardSession(client) {
|
|
10131
|
-
const raw = await
|
|
10132
|
-
|
|
10133
|
-
|
|
10513
|
+
const raw = await requestPortalFirstJson(
|
|
10514
|
+
client,
|
|
10515
|
+
"/guard/auth/session",
|
|
10516
|
+
{
|
|
10517
|
+
method: "GET"
|
|
10518
|
+
}
|
|
10519
|
+
);
|
|
10134
10520
|
return client.parseWithSchema(
|
|
10135
10521
|
raw,
|
|
10136
10522
|
guardSessionResponseSchema,
|
|
@@ -10138,9 +10524,13 @@ async function getGuardSession(client) {
|
|
|
10138
10524
|
);
|
|
10139
10525
|
}
|
|
10140
10526
|
async function getGuardEntitlements(client) {
|
|
10141
|
-
const raw = await
|
|
10142
|
-
|
|
10143
|
-
|
|
10527
|
+
const raw = await requestPortalFirstJson(
|
|
10528
|
+
client,
|
|
10529
|
+
"/guard/entitlements",
|
|
10530
|
+
{
|
|
10531
|
+
method: "GET"
|
|
10532
|
+
}
|
|
10533
|
+
);
|
|
10144
10534
|
return client.parseWithSchema(
|
|
10145
10535
|
raw,
|
|
10146
10536
|
guardSessionResponseSchema,
|
|
@@ -10148,9 +10538,13 @@ async function getGuardEntitlements(client) {
|
|
|
10148
10538
|
);
|
|
10149
10539
|
}
|
|
10150
10540
|
async function getGuardBillingBalance(client) {
|
|
10151
|
-
const raw = await
|
|
10152
|
-
|
|
10153
|
-
|
|
10541
|
+
const raw = await requestPortalFirstJson(
|
|
10542
|
+
client,
|
|
10543
|
+
"/guard/billing/balance",
|
|
10544
|
+
{
|
|
10545
|
+
method: "GET"
|
|
10546
|
+
}
|
|
10547
|
+
);
|
|
10154
10548
|
return client.parseWithSchema(
|
|
10155
10549
|
raw,
|
|
10156
10550
|
guardBalanceResponseSchema,
|
|
@@ -10164,9 +10558,13 @@ async function getGuardFeed(client, limit) {
|
|
|
10164
10558
|
}
|
|
10165
10559
|
const query = params.toString();
|
|
10166
10560
|
const suffix = query ? `?${query}` : "";
|
|
10167
|
-
const raw = await
|
|
10168
|
-
|
|
10169
|
-
|
|
10561
|
+
const raw = await requestPortalFirstJson(
|
|
10562
|
+
client,
|
|
10563
|
+
`/guard/feed${suffix}`,
|
|
10564
|
+
{
|
|
10565
|
+
method: "GET"
|
|
10566
|
+
}
|
|
10567
|
+
);
|
|
10170
10568
|
return client.parseWithSchema(
|
|
10171
10569
|
raw,
|
|
10172
10570
|
guardFeedResponseSchema,
|
|
@@ -10174,9 +10572,13 @@ async function getGuardFeed(client, limit) {
|
|
|
10174
10572
|
);
|
|
10175
10573
|
}
|
|
10176
10574
|
async function getGuardOverview(client) {
|
|
10177
|
-
const raw = await
|
|
10178
|
-
|
|
10179
|
-
|
|
10575
|
+
const raw = await requestPortalFirstJson(
|
|
10576
|
+
client,
|
|
10577
|
+
"/guard/overview",
|
|
10578
|
+
{
|
|
10579
|
+
method: "GET"
|
|
10580
|
+
}
|
|
10581
|
+
);
|
|
10180
10582
|
return client.parseWithSchema(
|
|
10181
10583
|
raw,
|
|
10182
10584
|
guardOverviewResponseSchema,
|
|
@@ -10188,7 +10590,8 @@ async function getGuardTrustByHash(client, sha2562) {
|
|
|
10188
10590
|
if (!normalizedHash) {
|
|
10189
10591
|
throw new Error("sha256 is required");
|
|
10190
10592
|
}
|
|
10191
|
-
const raw = await
|
|
10593
|
+
const raw = await requestPortalFirstJson(
|
|
10594
|
+
client,
|
|
10192
10595
|
`/guard/trust/by-hash/${encodeURIComponent(normalizedHash)}`,
|
|
10193
10596
|
{ method: "GET" }
|
|
10194
10597
|
);
|
|
@@ -10210,7 +10613,8 @@ async function resolveGuardTrust(client, query) {
|
|
|
10210
10613
|
params.set("version", query.version.trim());
|
|
10211
10614
|
}
|
|
10212
10615
|
const suffix = params.size > 0 ? `?${params.toString()}` : "";
|
|
10213
|
-
const raw = await
|
|
10616
|
+
const raw = await requestPortalFirstJson(
|
|
10617
|
+
client,
|
|
10214
10618
|
`/guard/trust/resolve${suffix}`,
|
|
10215
10619
|
{ method: "GET" }
|
|
10216
10620
|
);
|
|
@@ -10221,9 +10625,13 @@ async function resolveGuardTrust(client, query) {
|
|
|
10221
10625
|
);
|
|
10222
10626
|
}
|
|
10223
10627
|
async function getGuardRevocations(client) {
|
|
10224
|
-
const raw = await
|
|
10225
|
-
|
|
10226
|
-
|
|
10628
|
+
const raw = await requestPortalFirstJson(
|
|
10629
|
+
client,
|
|
10630
|
+
"/guard/revocations",
|
|
10631
|
+
{
|
|
10632
|
+
method: "GET"
|
|
10633
|
+
}
|
|
10634
|
+
);
|
|
10227
10635
|
return client.parseWithSchema(
|
|
10228
10636
|
raw,
|
|
10229
10637
|
guardRevocationResponseSchema,
|
|
@@ -10231,9 +10639,13 @@ async function getGuardRevocations(client) {
|
|
|
10231
10639
|
);
|
|
10232
10640
|
}
|
|
10233
10641
|
async function fetchGuardAdvisories(client) {
|
|
10234
|
-
const raw = await
|
|
10235
|
-
|
|
10236
|
-
|
|
10642
|
+
const raw = await requestPortalFirstJson(
|
|
10643
|
+
client,
|
|
10644
|
+
"/guard/advisories",
|
|
10645
|
+
{
|
|
10646
|
+
method: "GET"
|
|
10647
|
+
}
|
|
10648
|
+
);
|
|
10237
10649
|
return client.parseWithSchema(
|
|
10238
10650
|
raw,
|
|
10239
10651
|
guardRevocationResponseSchema,
|
|
@@ -10241,9 +10653,13 @@ async function fetchGuardAdvisories(client) {
|
|
|
10241
10653
|
);
|
|
10242
10654
|
}
|
|
10243
10655
|
async function fetchGuardPolicy(client) {
|
|
10244
|
-
const raw = await
|
|
10245
|
-
|
|
10246
|
-
|
|
10656
|
+
const raw = await requestPortalFirstJson(
|
|
10657
|
+
client,
|
|
10658
|
+
"/guard/policy/fetch",
|
|
10659
|
+
{
|
|
10660
|
+
method: "GET"
|
|
10661
|
+
}
|
|
10662
|
+
);
|
|
10247
10663
|
return client.parseWithSchema(
|
|
10248
10664
|
raw,
|
|
10249
10665
|
guardPolicySchema,
|
|
@@ -10251,9 +10667,13 @@ async function fetchGuardPolicy(client) {
|
|
|
10251
10667
|
);
|
|
10252
10668
|
}
|
|
10253
10669
|
async function getGuardInventory(client) {
|
|
10254
|
-
const raw = await
|
|
10255
|
-
|
|
10256
|
-
|
|
10670
|
+
const raw = await requestPortalFirstJson(
|
|
10671
|
+
client,
|
|
10672
|
+
"/guard/inventory",
|
|
10673
|
+
{
|
|
10674
|
+
method: "GET"
|
|
10675
|
+
}
|
|
10676
|
+
);
|
|
10257
10677
|
return client.parseWithSchema(
|
|
10258
10678
|
raw,
|
|
10259
10679
|
guardInventoryResponseSchema,
|
|
@@ -10261,9 +10681,13 @@ async function getGuardInventory(client) {
|
|
|
10261
10681
|
);
|
|
10262
10682
|
}
|
|
10263
10683
|
async function getGuardReceiptHistory(client) {
|
|
10264
|
-
const raw = await
|
|
10265
|
-
|
|
10266
|
-
|
|
10684
|
+
const raw = await requestPortalFirstJson(
|
|
10685
|
+
client,
|
|
10686
|
+
"/guard/history",
|
|
10687
|
+
{
|
|
10688
|
+
method: "GET"
|
|
10689
|
+
}
|
|
10690
|
+
);
|
|
10267
10691
|
return client.parseWithSchema(
|
|
10268
10692
|
raw,
|
|
10269
10693
|
guardReceiptHistoryResponseSchema,
|
|
@@ -10275,7 +10699,8 @@ async function getGuardArtifactTimeline(client, artifactId) {
|
|
|
10275
10699
|
if (!normalizedArtifactId) {
|
|
10276
10700
|
throw new Error("artifactId is required");
|
|
10277
10701
|
}
|
|
10278
|
-
const raw = await
|
|
10702
|
+
const raw = await requestPortalFirstJson(
|
|
10703
|
+
client,
|
|
10279
10704
|
`/guard/history/${encodeURIComponent(normalizedArtifactId)}`,
|
|
10280
10705
|
{ method: "GET" }
|
|
10281
10706
|
);
|
|
@@ -10286,7 +10711,7 @@ async function getGuardArtifactTimeline(client, artifactId) {
|
|
|
10286
10711
|
);
|
|
10287
10712
|
}
|
|
10288
10713
|
async function exportGuardAbom(client) {
|
|
10289
|
-
const raw = await client
|
|
10714
|
+
const raw = await requestPortalFirstJson(client, "/guard/abom", {
|
|
10290
10715
|
method: "GET"
|
|
10291
10716
|
});
|
|
10292
10717
|
return client.parseWithSchema(
|
|
@@ -10300,7 +10725,8 @@ async function exportGuardArtifactAbom(client, artifactId) {
|
|
|
10300
10725
|
if (!normalizedArtifactId) {
|
|
10301
10726
|
throw new Error("artifactId is required");
|
|
10302
10727
|
}
|
|
10303
|
-
const raw = await
|
|
10728
|
+
const raw = await requestPortalFirstJson(
|
|
10729
|
+
client,
|
|
10304
10730
|
`/guard/abom/${encodeURIComponent(normalizedArtifactId)}`,
|
|
10305
10731
|
{ method: "GET" }
|
|
10306
10732
|
);
|
|
@@ -10311,9 +10737,13 @@ async function exportGuardArtifactAbom(client, artifactId) {
|
|
|
10311
10737
|
);
|
|
10312
10738
|
}
|
|
10313
10739
|
async function exportGuardReceipts(client) {
|
|
10314
|
-
const raw = await
|
|
10315
|
-
|
|
10316
|
-
|
|
10740
|
+
const raw = await requestPortalFirstJson(
|
|
10741
|
+
client,
|
|
10742
|
+
"/guard/receipts/export",
|
|
10743
|
+
{
|
|
10744
|
+
method: "GET"
|
|
10745
|
+
}
|
|
10746
|
+
);
|
|
10317
10747
|
return client.parseWithSchema(
|
|
10318
10748
|
raw,
|
|
10319
10749
|
guardReceiptExportResponseSchema,
|
|
@@ -10321,9 +10751,13 @@ async function exportGuardReceipts(client) {
|
|
|
10321
10751
|
);
|
|
10322
10752
|
}
|
|
10323
10753
|
async function getGuardInventoryDiff(client) {
|
|
10324
|
-
const raw = await
|
|
10325
|
-
|
|
10326
|
-
|
|
10754
|
+
const raw = await requestPortalFirstJson(
|
|
10755
|
+
client,
|
|
10756
|
+
"/guard/inventory/diff",
|
|
10757
|
+
{
|
|
10758
|
+
method: "GET"
|
|
10759
|
+
}
|
|
10760
|
+
);
|
|
10327
10761
|
return client.parseWithSchema(
|
|
10328
10762
|
raw,
|
|
10329
10763
|
guardInventoryDiffResponseSchema,
|
|
@@ -10331,9 +10765,13 @@ async function getGuardInventoryDiff(client) {
|
|
|
10331
10765
|
);
|
|
10332
10766
|
}
|
|
10333
10767
|
async function getGuardDevices(client) {
|
|
10334
|
-
const raw = await
|
|
10335
|
-
|
|
10336
|
-
|
|
10768
|
+
const raw = await requestPortalFirstJson(
|
|
10769
|
+
client,
|
|
10770
|
+
"/guard/devices",
|
|
10771
|
+
{
|
|
10772
|
+
method: "GET"
|
|
10773
|
+
}
|
|
10774
|
+
);
|
|
10337
10775
|
return client.parseWithSchema(
|
|
10338
10776
|
raw,
|
|
10339
10777
|
guardDeviceListResponseSchema,
|
|
@@ -10341,9 +10779,13 @@ async function getGuardDevices(client) {
|
|
|
10341
10779
|
);
|
|
10342
10780
|
}
|
|
10343
10781
|
async function getGuardAlertPreferences(client) {
|
|
10344
|
-
const raw = await
|
|
10345
|
-
|
|
10346
|
-
|
|
10782
|
+
const raw = await requestPortalFirstJson(
|
|
10783
|
+
client,
|
|
10784
|
+
"/guard/alerts/preferences",
|
|
10785
|
+
{
|
|
10786
|
+
method: "GET"
|
|
10787
|
+
}
|
|
10788
|
+
);
|
|
10347
10789
|
return client.parseWithSchema(
|
|
10348
10790
|
raw,
|
|
10349
10791
|
guardAlertPreferencesSchema,
|
|
@@ -10351,10 +10793,14 @@ async function getGuardAlertPreferences(client) {
|
|
|
10351
10793
|
);
|
|
10352
10794
|
}
|
|
10353
10795
|
async function updateGuardAlertPreferences(client, payload) {
|
|
10354
|
-
const raw = await
|
|
10355
|
-
|
|
10356
|
-
|
|
10357
|
-
|
|
10796
|
+
const raw = await requestPortalFirstJson(
|
|
10797
|
+
client,
|
|
10798
|
+
"/guard/alerts/preferences",
|
|
10799
|
+
{
|
|
10800
|
+
method: "PUT",
|
|
10801
|
+
body: payload
|
|
10802
|
+
}
|
|
10803
|
+
);
|
|
10358
10804
|
return client.parseWithSchema(
|
|
10359
10805
|
raw,
|
|
10360
10806
|
guardAlertPreferencesSchema,
|
|
@@ -10362,9 +10808,13 @@ async function updateGuardAlertPreferences(client, payload) {
|
|
|
10362
10808
|
);
|
|
10363
10809
|
}
|
|
10364
10810
|
async function getGuardExceptions(client) {
|
|
10365
|
-
const raw = await
|
|
10366
|
-
|
|
10367
|
-
|
|
10811
|
+
const raw = await requestPortalFirstJson(
|
|
10812
|
+
client,
|
|
10813
|
+
"/guard/exceptions",
|
|
10814
|
+
{
|
|
10815
|
+
method: "GET"
|
|
10816
|
+
}
|
|
10817
|
+
);
|
|
10368
10818
|
return client.parseWithSchema(
|
|
10369
10819
|
raw,
|
|
10370
10820
|
guardExceptionListResponseSchema,
|
|
@@ -10372,9 +10822,13 @@ async function getGuardExceptions(client) {
|
|
|
10372
10822
|
);
|
|
10373
10823
|
}
|
|
10374
10824
|
async function getGuardWatchlist(client) {
|
|
10375
|
-
const raw = await
|
|
10376
|
-
|
|
10377
|
-
|
|
10825
|
+
const raw = await requestPortalFirstJson(
|
|
10826
|
+
client,
|
|
10827
|
+
"/guard/watchlist",
|
|
10828
|
+
{
|
|
10829
|
+
method: "GET"
|
|
10830
|
+
}
|
|
10831
|
+
);
|
|
10378
10832
|
return client.parseWithSchema(
|
|
10379
10833
|
raw,
|
|
10380
10834
|
guardWatchlistResponseSchema,
|
|
@@ -10382,10 +10836,14 @@ async function getGuardWatchlist(client) {
|
|
|
10382
10836
|
);
|
|
10383
10837
|
}
|
|
10384
10838
|
async function lookupGuardWatchlist(client, payload) {
|
|
10385
|
-
const raw = await
|
|
10386
|
-
|
|
10387
|
-
|
|
10388
|
-
|
|
10839
|
+
const raw = await requestPortalFirstJson(
|
|
10840
|
+
client,
|
|
10841
|
+
"/guard/watchlist/lookup",
|
|
10842
|
+
{
|
|
10843
|
+
method: "POST",
|
|
10844
|
+
body: payload
|
|
10845
|
+
}
|
|
10846
|
+
);
|
|
10389
10847
|
return client.parseWithSchema(
|
|
10390
10848
|
raw,
|
|
10391
10849
|
guardWatchlistLookupResponseSchema,
|
|
@@ -10393,9 +10851,13 @@ async function lookupGuardWatchlist(client, payload) {
|
|
|
10393
10851
|
);
|
|
10394
10852
|
}
|
|
10395
10853
|
async function getGuardPainSignals(client) {
|
|
10396
|
-
const raw = await
|
|
10397
|
-
|
|
10398
|
-
|
|
10854
|
+
const raw = await requestPortalFirstJson(
|
|
10855
|
+
client,
|
|
10856
|
+
"/guard/signals/pain",
|
|
10857
|
+
{
|
|
10858
|
+
method: "GET"
|
|
10859
|
+
}
|
|
10860
|
+
);
|
|
10399
10861
|
return client.parseWithSchema(
|
|
10400
10862
|
raw,
|
|
10401
10863
|
guardPainSignalListResponseSchema,
|
|
@@ -10403,7 +10865,8 @@ async function getGuardPainSignals(client) {
|
|
|
10403
10865
|
);
|
|
10404
10866
|
}
|
|
10405
10867
|
async function getGuardAggregatedPainSignals(client) {
|
|
10406
|
-
const raw = await
|
|
10868
|
+
const raw = await requestPortalFirstJson(
|
|
10869
|
+
client,
|
|
10407
10870
|
"/guard/signals/pain/aggregate",
|
|
10408
10871
|
{
|
|
10409
10872
|
method: "GET"
|
|
@@ -10416,7 +10879,7 @@ async function getGuardAggregatedPainSignals(client) {
|
|
|
10416
10879
|
);
|
|
10417
10880
|
}
|
|
10418
10881
|
async function getGuardPreflightVerdict(client, path, payload) {
|
|
10419
|
-
const raw = await client
|
|
10882
|
+
const raw = await requestPortalFirstJson(client, path, {
|
|
10420
10883
|
method: "POST",
|
|
10421
10884
|
body: payload
|
|
10422
10885
|
});
|
|
@@ -10441,10 +10904,14 @@ async function getGuardPreExecutionVerdict(client, payload) {
|
|
|
10441
10904
|
);
|
|
10442
10905
|
}
|
|
10443
10906
|
async function ingestGuardPainSignals(client, items) {
|
|
10444
|
-
const raw = await
|
|
10445
|
-
|
|
10446
|
-
|
|
10447
|
-
|
|
10907
|
+
const raw = await requestPortalFirstJson(
|
|
10908
|
+
client,
|
|
10909
|
+
"/guard/signals/pain",
|
|
10910
|
+
{
|
|
10911
|
+
method: "POST",
|
|
10912
|
+
body: { items }
|
|
10913
|
+
}
|
|
10914
|
+
);
|
|
10448
10915
|
return client.parseWithSchema(
|
|
10449
10916
|
raw,
|
|
10450
10917
|
guardPainSignalListResponseSchema,
|
|
@@ -10452,10 +10919,14 @@ async function ingestGuardPainSignals(client, items) {
|
|
|
10452
10919
|
);
|
|
10453
10920
|
}
|
|
10454
10921
|
async function submitGuardReceipts(client, payload) {
|
|
10455
|
-
const raw = await
|
|
10456
|
-
|
|
10457
|
-
|
|
10458
|
-
|
|
10922
|
+
const raw = await requestPortalFirstJson(
|
|
10923
|
+
client,
|
|
10924
|
+
"/guard/receipts/submit",
|
|
10925
|
+
{
|
|
10926
|
+
method: "POST",
|
|
10927
|
+
body: payload
|
|
10928
|
+
}
|
|
10929
|
+
);
|
|
10459
10930
|
return client.parseWithSchema(
|
|
10460
10931
|
raw,
|
|
10461
10932
|
guardReceiptSyncResponseSchema,
|
|
@@ -10463,10 +10934,14 @@ async function submitGuardReceipts(client, payload) {
|
|
|
10463
10934
|
);
|
|
10464
10935
|
}
|
|
10465
10936
|
async function addGuardWatchlistItem(client, payload) {
|
|
10466
|
-
const raw = await
|
|
10467
|
-
|
|
10468
|
-
|
|
10469
|
-
|
|
10937
|
+
const raw = await requestPortalFirstJson(
|
|
10938
|
+
client,
|
|
10939
|
+
"/guard/watchlist",
|
|
10940
|
+
{
|
|
10941
|
+
method: "POST",
|
|
10942
|
+
body: payload
|
|
10943
|
+
}
|
|
10944
|
+
);
|
|
10470
10945
|
return client.parseWithSchema(
|
|
10471
10946
|
raw,
|
|
10472
10947
|
guardWatchlistResponseSchema,
|
|
@@ -10478,7 +10953,8 @@ async function removeGuardWatchlistItem(client, artifactId) {
|
|
|
10478
10953
|
if (!normalizedArtifactId) {
|
|
10479
10954
|
throw new Error("artifactId is required");
|
|
10480
10955
|
}
|
|
10481
|
-
const raw = await
|
|
10956
|
+
const raw = await requestPortalFirstJson(
|
|
10957
|
+
client,
|
|
10482
10958
|
`/guard/watchlist/${encodeURIComponent(normalizedArtifactId)}`,
|
|
10483
10959
|
{ method: "DELETE" }
|
|
10484
10960
|
);
|
|
@@ -10489,10 +10965,14 @@ async function removeGuardWatchlistItem(client, artifactId) {
|
|
|
10489
10965
|
);
|
|
10490
10966
|
}
|
|
10491
10967
|
async function addGuardException(client, payload) {
|
|
10492
|
-
const raw = await
|
|
10493
|
-
|
|
10494
|
-
|
|
10495
|
-
|
|
10968
|
+
const raw = await requestPortalFirstJson(
|
|
10969
|
+
client,
|
|
10970
|
+
"/guard/exceptions",
|
|
10971
|
+
{
|
|
10972
|
+
method: "POST",
|
|
10973
|
+
body: payload
|
|
10974
|
+
}
|
|
10975
|
+
);
|
|
10496
10976
|
return client.parseWithSchema(
|
|
10497
10977
|
raw,
|
|
10498
10978
|
guardExceptionListResponseSchema,
|
|
@@ -10500,10 +10980,14 @@ async function addGuardException(client, payload) {
|
|
|
10500
10980
|
);
|
|
10501
10981
|
}
|
|
10502
10982
|
async function requestGuardException(client, payload) {
|
|
10503
|
-
const raw = await
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
|
|
10983
|
+
const raw = await requestPortalFirstJson(
|
|
10984
|
+
client,
|
|
10985
|
+
"/guard/exceptions/request",
|
|
10986
|
+
{
|
|
10987
|
+
method: "POST",
|
|
10988
|
+
body: payload
|
|
10989
|
+
}
|
|
10990
|
+
);
|
|
10507
10991
|
return client.parseWithSchema(
|
|
10508
10992
|
raw,
|
|
10509
10993
|
guardExceptionListResponseSchema,
|
|
@@ -10511,10 +10995,14 @@ async function requestGuardException(client, payload) {
|
|
|
10511
10995
|
);
|
|
10512
10996
|
}
|
|
10513
10997
|
async function syncGuardInventory(client, payload) {
|
|
10514
|
-
const raw = await
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10998
|
+
const raw = await requestPortalFirstJson(
|
|
10999
|
+
client,
|
|
11000
|
+
"/guard/inventory/sync",
|
|
11001
|
+
{
|
|
11002
|
+
method: "POST",
|
|
11003
|
+
body: payload
|
|
11004
|
+
}
|
|
11005
|
+
);
|
|
10518
11006
|
return client.parseWithSchema(
|
|
10519
11007
|
raw,
|
|
10520
11008
|
guardReceiptSyncResponseSchema,
|
|
@@ -10526,7 +11014,8 @@ async function removeGuardException(client, exceptionId) {
|
|
|
10526
11014
|
if (!normalizedExceptionId) {
|
|
10527
11015
|
throw new Error("exceptionId is required");
|
|
10528
11016
|
}
|
|
10529
|
-
const raw = await
|
|
11017
|
+
const raw = await requestPortalFirstJson(
|
|
11018
|
+
client,
|
|
10530
11019
|
`/guard/exceptions/${encodeURIComponent(normalizedExceptionId)}`,
|
|
10531
11020
|
{ method: "DELETE" }
|
|
10532
11021
|
);
|
|
@@ -10537,9 +11026,13 @@ async function removeGuardException(client, exceptionId) {
|
|
|
10537
11026
|
);
|
|
10538
11027
|
}
|
|
10539
11028
|
async function getGuardTeamPolicyPack(client) {
|
|
10540
|
-
const raw = await
|
|
10541
|
-
|
|
10542
|
-
|
|
11029
|
+
const raw = await requestPortalFirstJson(
|
|
11030
|
+
client,
|
|
11031
|
+
"/guard/team/policy-pack",
|
|
11032
|
+
{
|
|
11033
|
+
method: "GET"
|
|
11034
|
+
}
|
|
11035
|
+
);
|
|
10543
11036
|
return client.parseWithSchema(
|
|
10544
11037
|
raw,
|
|
10545
11038
|
guardTeamPolicyPackSchema,
|
|
@@ -10547,10 +11040,14 @@ async function getGuardTeamPolicyPack(client) {
|
|
|
10547
11040
|
);
|
|
10548
11041
|
}
|
|
10549
11042
|
async function updateGuardTeamPolicyPack(client, payload) {
|
|
10550
|
-
const raw = await
|
|
10551
|
-
|
|
10552
|
-
|
|
10553
|
-
|
|
11043
|
+
const raw = await requestPortalFirstJson(
|
|
11044
|
+
client,
|
|
11045
|
+
"/guard/team/policy-pack",
|
|
11046
|
+
{
|
|
11047
|
+
method: "PUT",
|
|
11048
|
+
body: payload
|
|
11049
|
+
}
|
|
11050
|
+
);
|
|
10554
11051
|
return client.parseWithSchema(
|
|
10555
11052
|
raw,
|
|
10556
11053
|
guardTeamPolicyPackSchema,
|
|
@@ -10558,10 +11055,14 @@ async function updateGuardTeamPolicyPack(client, payload) {
|
|
|
10558
11055
|
);
|
|
10559
11056
|
}
|
|
10560
11057
|
async function syncGuardReceipts(client, payload) {
|
|
10561
|
-
const raw = await
|
|
10562
|
-
|
|
10563
|
-
|
|
10564
|
-
|
|
11058
|
+
const raw = await requestPortalFirstJson(
|
|
11059
|
+
client,
|
|
11060
|
+
"/guard/receipts/sync",
|
|
11061
|
+
{
|
|
11062
|
+
method: "POST",
|
|
11063
|
+
body: payload
|
|
11064
|
+
}
|
|
11065
|
+
);
|
|
10565
11066
|
return client.parseWithSchema(
|
|
10566
11067
|
raw,
|
|
10567
11068
|
guardReceiptSyncResponseSchema,
|
|
@@ -11882,7 +12383,7 @@ class RegistryBrokerClient {
|
|
|
11882
12383
|
const normalisedPath = path.startsWith("/") ? path : `/${path}`;
|
|
11883
12384
|
return `${this.baseUrl}${normalisedPath}`;
|
|
11884
12385
|
}
|
|
11885
|
-
|
|
12386
|
+
buildRequestInit(config) {
|
|
11886
12387
|
const headers = new Headers();
|
|
11887
12388
|
Object.entries(this.defaultHeaders).forEach(([key, value]) => {
|
|
11888
12389
|
headers.set(key, value);
|
|
@@ -11908,6 +12409,10 @@ class RegistryBrokerClient {
|
|
|
11908
12409
|
headers.set("content-type", "application/json");
|
|
11909
12410
|
}
|
|
11910
12411
|
}
|
|
12412
|
+
return init;
|
|
12413
|
+
}
|
|
12414
|
+
async request(path, config) {
|
|
12415
|
+
const init = this.buildRequestInit(config);
|
|
11911
12416
|
const response = await this.fetchImpl(this.buildUrl(path), init);
|
|
11912
12417
|
if (response.ok) {
|
|
11913
12418
|
return response;
|
|
@@ -11919,6 +12424,19 @@ class RegistryBrokerClient {
|
|
|
11919
12424
|
body: errorBody
|
|
11920
12425
|
});
|
|
11921
12426
|
}
|
|
12427
|
+
async requestAbsolute(url, config) {
|
|
12428
|
+
const init = this.buildRequestInit(config);
|
|
12429
|
+
const response = await this.fetchImpl(url, init);
|
|
12430
|
+
if (response.ok) {
|
|
12431
|
+
return response;
|
|
12432
|
+
}
|
|
12433
|
+
const errorBody = await this.extractErrorBody(response);
|
|
12434
|
+
throw new RegistryBrokerError("Registry broker request failed", {
|
|
12435
|
+
status: response.status,
|
|
12436
|
+
statusText: response.statusText,
|
|
12437
|
+
body: errorBody
|
|
12438
|
+
});
|
|
12439
|
+
}
|
|
11922
12440
|
async requestJson(path, config) {
|
|
11923
12441
|
const response = await this.request(path, config);
|
|
11924
12442
|
const contentType = response.headers?.get("content-type") ?? "";
|
|
@@ -11931,6 +12449,18 @@ class RegistryBrokerClient {
|
|
|
11931
12449
|
}
|
|
11932
12450
|
return await response.json();
|
|
11933
12451
|
}
|
|
12452
|
+
async requestAbsoluteJson(url, config) {
|
|
12453
|
+
const response = await this.requestAbsolute(url, config);
|
|
12454
|
+
const contentType = response.headers?.get("content-type") ?? "";
|
|
12455
|
+
if (!JSON_CONTENT_TYPE.test(contentType)) {
|
|
12456
|
+
const body = await response.text();
|
|
12457
|
+
throw new RegistryBrokerParseError(
|
|
12458
|
+
"Expected JSON response from registry broker",
|
|
12459
|
+
body
|
|
12460
|
+
);
|
|
12461
|
+
}
|
|
12462
|
+
return await response.json();
|
|
12463
|
+
}
|
|
11934
12464
|
async getAgentFeedback(uaid, options = {}) {
|
|
11935
12465
|
const normalized = uaid.trim();
|
|
11936
12466
|
if (!normalized) {
|
|
@@ -12565,6 +13095,9 @@ class RegistryBrokerClient {
|
|
|
12565
13095
|
async createSession(payload, allowHistoryAutoTopUp = true) {
|
|
12566
13096
|
return createSession(this, payload, allowHistoryAutoTopUp);
|
|
12567
13097
|
}
|
|
13098
|
+
async checkChatReadiness(payload) {
|
|
13099
|
+
return checkChatReadiness(this, payload);
|
|
13100
|
+
}
|
|
12568
13101
|
async startChat(options) {
|
|
12569
13102
|
return startChat(this, this.getEncryptedChatManager(), options);
|
|
12570
13103
|
}
|
|
@@ -12590,6 +13123,12 @@ class RegistryBrokerClient {
|
|
|
12590
13123
|
sendMessage(payload) {
|
|
12591
13124
|
return sendMessage(this, payload);
|
|
12592
13125
|
}
|
|
13126
|
+
retryMessage(messageId, payload) {
|
|
13127
|
+
return retryMessage(this, messageId, payload);
|
|
13128
|
+
}
|
|
13129
|
+
cancelSession(sessionId) {
|
|
13130
|
+
return cancelSession(this, sessionId);
|
|
13131
|
+
}
|
|
12593
13132
|
endSession(sessionId) {
|
|
12594
13133
|
return endSession(this, sessionId);
|
|
12595
13134
|
}
|
|
@@ -12855,6 +13394,8 @@ class RegistryBrokerClient {
|
|
|
12855
13394
|
const isPendingRegisterAgentResponse = (response) => response.status === "pending";
|
|
12856
13395
|
const isPartialRegisterAgentResponse = (response) => response.status === "partial" && response.success === false;
|
|
12857
13396
|
const isSuccessRegisterAgentResponse = (response) => response.success === true && response.status !== "pending";
|
|
13397
|
+
const GUARD_CANONICAL_PATH_PREFIX = "/api/guard";
|
|
13398
|
+
const GUARD_COMPAT_PATH_PREFIX = "/guard";
|
|
12858
13399
|
const HOL_CHAT_PROTOCOL_ID = "hol-chat";
|
|
12859
13400
|
const isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
12860
13401
|
const isHolChatOp = (value) => {
|
|
@@ -43225,6 +43766,8 @@ const index = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePropert
|
|
|
43225
43766
|
traditionalChinese: wordlist
|
|
43226
43767
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
43227
43768
|
export {
|
|
43769
|
+
GUARD_CANONICAL_PATH_PREFIX,
|
|
43770
|
+
GUARD_COMPAT_PATH_PREFIX,
|
|
43228
43771
|
HOL_CHAT_PROTOCOL_ID,
|
|
43229
43772
|
Logger,
|
|
43230
43773
|
RegistryBrokerClient,
|