@hashgraphonline/standards-sdk 0.1.187 → 0.1.189
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/agent-network.d.ts +1118 -0
- package/dist/browser/services/registry-broker/client/agent-network.d.ts.map +1 -0
- package/dist/browser/services/registry-broker/client/base-client.d.ts +4 -0
- package/dist/browser/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/browser/services/registry-broker/client.d.ts +1 -0
- package/dist/browser/services/registry-broker/client.d.ts.map +1 -1
- package/dist/browser/standards-sdk.browser.js +176 -0
- package/dist/browser/standards-sdk.browser.js.map +1 -1
- package/dist/browser-root/services/registry-broker/client/agent-network.d.ts +1118 -0
- package/dist/browser-root/services/registry-broker/client/agent-network.d.ts.map +1 -0
- package/dist/browser-root/services/registry-broker/client/base-client.d.ts +4 -0
- package/dist/browser-root/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/browser-root/services/registry-broker/client.d.ts +1 -0
- package/dist/browser-root/services/registry-broker/client.d.ts.map +1 -1
- package/dist/browser-root/standards-sdk.root-browser.js +471 -15
- package/dist/browser-root/standards-sdk.root-browser.js.map +1 -1
- package/dist/cjs/services/registry-broker/client/agent-network.d.ts +1118 -0
- package/dist/cjs/services/registry-broker/client/agent-network.d.ts.map +1 -0
- package/dist/cjs/services/registry-broker/client/base-client.d.ts +4 -0
- package/dist/cjs/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/cjs/services/registry-broker/client.d.ts +1 -0
- package/dist/cjs/services/registry-broker/client.d.ts.map +1 -1
- package/dist/cjs/standards-sdk.cjs +2 -2
- package/dist/cjs/standards-sdk.cjs.map +1 -1
- package/dist/es/services/registry-broker/client/agent-network.d.ts +1118 -0
- package/dist/es/services/registry-broker/client/agent-network.d.ts.map +1 -0
- package/dist/es/services/registry-broker/client/base-client.d.ts +4 -0
- package/dist/es/services/registry-broker/client/base-client.d.ts.map +1 -1
- package/dist/es/services/registry-broker/client.d.ts +1 -0
- package/dist/es/services/registry-broker/client.d.ts.map +1 -1
- package/dist/es/standards-sdk.es.js +54 -27
- 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.es120.js +4 -4
- package/dist/es/standards-sdk.es121.js +11 -11
- package/dist/es/standards-sdk.es126.js +1 -1
- package/dist/es/standards-sdk.es132.js +3 -2
- package/dist/es/standards-sdk.es132.js.map +1 -1
- package/dist/es/standards-sdk.es147.js +3 -3
- package/dist/es/standards-sdk.es148.js +1 -1
- package/dist/es/standards-sdk.es150.js +24 -15
- package/dist/es/standards-sdk.es150.js.map +1 -1
- package/dist/es/standards-sdk.es152.js +440 -248
- package/dist/es/standards-sdk.es152.js.map +1 -1
- package/dist/es/standards-sdk.es153.js +259 -4
- package/dist/es/standards-sdk.es153.js.map +1 -1
- package/dist/es/standards-sdk.es154.js +4 -81
- package/dist/es/standards-sdk.es154.js.map +1 -1
- package/dist/es/standards-sdk.es155.js +71 -77
- package/dist/es/standards-sdk.es155.js.map +1 -1
- package/dist/es/standards-sdk.es156.js +80 -53
- package/dist/es/standards-sdk.es156.js.map +1 -1
- package/dist/es/standards-sdk.es157.js +59 -2546
- package/dist/es/standards-sdk.es157.js.map +1 -1
- package/dist/es/standards-sdk.es158.js +2547 -159
- package/dist/es/standards-sdk.es158.js.map +1 -1
- package/dist/es/standards-sdk.es159.js +159 -7
- package/dist/es/standards-sdk.es159.js.map +1 -1
- package/dist/es/standards-sdk.es16.js +3 -2
- package/dist/es/standards-sdk.es16.js.map +1 -1
- package/dist/es/standards-sdk.es160.js +7 -86
- package/dist/es/standards-sdk.es160.js.map +1 -1
- package/dist/es/standards-sdk.es161.js +64 -43
- package/dist/es/standards-sdk.es161.js.map +1 -1
- package/dist/es/standards-sdk.es162.js +57 -186
- package/dist/es/standards-sdk.es162.js.map +1 -1
- package/dist/es/standards-sdk.es163.js +188 -20
- package/dist/es/standards-sdk.es163.js.map +1 -1
- package/dist/es/standards-sdk.es164.js +22 -54
- package/dist/es/standards-sdk.es164.js.map +1 -1
- package/dist/es/standards-sdk.es165.js +41 -78
- package/dist/es/standards-sdk.es165.js.map +1 -1
- package/dist/es/standards-sdk.es166.js +81 -35
- package/dist/es/standards-sdk.es166.js.map +1 -1
- package/dist/es/standards-sdk.es167.js +36 -191
- package/dist/es/standards-sdk.es167.js.map +1 -1
- package/dist/es/standards-sdk.es168.js +191 -43
- package/dist/es/standards-sdk.es168.js.map +1 -1
- package/dist/es/standards-sdk.es169.js +46 -39
- package/dist/es/standards-sdk.es169.js.map +1 -1
- package/dist/es/standards-sdk.es170.js +37 -44
- package/dist/es/standards-sdk.es170.js.map +1 -1
- package/dist/es/standards-sdk.es171.js +46 -39
- package/dist/es/standards-sdk.es171.js.map +1 -1
- package/dist/es/standards-sdk.es172.js +29 -102
- package/dist/es/standards-sdk.es172.js.map +1 -1
- package/dist/es/standards-sdk.es173.js +104 -36
- package/dist/es/standards-sdk.es173.js.map +1 -1
- package/dist/es/standards-sdk.es174.js +43 -33
- package/dist/es/standards-sdk.es174.js.map +1 -1
- package/dist/es/standards-sdk.es175.js +44 -72
- package/dist/es/standards-sdk.es175.js.map +1 -1
- package/dist/es/standards-sdk.es176.js +65 -61
- package/dist/es/standards-sdk.es176.js.map +1 -1
- package/dist/es/standards-sdk.es177.js +63 -39
- package/dist/es/standards-sdk.es177.js.map +1 -1
- package/dist/es/standards-sdk.es178.js +44 -36
- package/dist/es/standards-sdk.es178.js.map +1 -1
- package/dist/es/standards-sdk.es179.js +36 -30
- package/dist/es/standards-sdk.es179.js.map +1 -1
- package/dist/es/standards-sdk.es18.js +6 -5
- package/dist/es/standards-sdk.es18.js.map +1 -1
- package/dist/es/standards-sdk.es180.js +30 -34
- package/dist/es/standards-sdk.es180.js.map +1 -1
- package/dist/es/standards-sdk.es181.js +34 -48
- package/dist/es/standards-sdk.es181.js.map +1 -1
- package/dist/es/standards-sdk.es182.js +48 -138
- package/dist/es/standards-sdk.es182.js.map +1 -1
- package/dist/es/standards-sdk.es183.js +133 -37
- package/dist/es/standards-sdk.es183.js.map +1 -1
- package/dist/es/standards-sdk.es184.js +34 -12474
- package/dist/es/standards-sdk.es184.js.map +1 -1
- package/dist/es/standards-sdk.es185.js +12425 -615
- package/dist/es/standards-sdk.es185.js.map +1 -1
- package/dist/es/standards-sdk.es186.js +47 -102
- package/dist/es/standards-sdk.es186.js.map +1 -1
- package/dist/es/standards-sdk.es187.js +96 -58
- package/dist/es/standards-sdk.es187.js.map +1 -1
- package/dist/es/standards-sdk.es188.js +73 -48
- package/dist/es/standards-sdk.es188.js.map +1 -1
- package/dist/es/standards-sdk.es189.js +180 -61
- package/dist/es/standards-sdk.es189.js.map +1 -1
- package/dist/es/standards-sdk.es19.js +4 -3
- package/dist/es/standards-sdk.es19.js.map +1 -1
- package/dist/es/standards-sdk.es190.js +659 -187
- package/dist/es/standards-sdk.es190.js.map +1 -1
- package/dist/es/standards-sdk.es197.js +71 -15
- package/dist/es/standards-sdk.es197.js.map +1 -1
- package/dist/es/standards-sdk.es198.js +14 -136
- package/dist/es/standards-sdk.es198.js.map +1 -1
- package/dist/es/standards-sdk.es199.js +104 -482
- package/dist/es/standards-sdk.es199.js.map +1 -1
- package/dist/es/standards-sdk.es200.js +480 -222
- package/dist/es/standards-sdk.es200.js.map +1 -1
- package/dist/es/standards-sdk.es201.js +239 -176
- package/dist/es/standards-sdk.es201.js.map +1 -1
- package/dist/es/standards-sdk.es202.js +178 -101
- package/dist/es/standards-sdk.es202.js.map +1 -1
- package/dist/es/standards-sdk.es203.js +75 -108
- package/dist/es/standards-sdk.es203.js.map +1 -1
- package/dist/es/standards-sdk.es204.js +116 -148
- package/dist/es/standards-sdk.es204.js.map +1 -1
- package/dist/es/standards-sdk.es205.js +146 -646
- package/dist/es/standards-sdk.es205.js.map +1 -1
- package/dist/es/standards-sdk.es206.js +661 -162
- package/dist/es/standards-sdk.es206.js.map +1 -1
- package/dist/es/standards-sdk.es207.js +156 -206
- package/dist/es/standards-sdk.es207.js.map +1 -1
- package/dist/es/standards-sdk.es208.js +219 -223
- package/dist/es/standards-sdk.es208.js.map +1 -1
- package/dist/es/standards-sdk.es209.js +242 -0
- package/dist/es/standards-sdk.es209.js.map +1 -0
- package/dist/es/standards-sdk.es22.js +1 -1
- package/dist/es/standards-sdk.es27.js +6 -5
- package/dist/es/standards-sdk.es27.js.map +1 -1
- 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 +4 -3
- package/dist/es/standards-sdk.es35.js.map +1 -1
- 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 +4 -3
- package/dist/es/standards-sdk.es67.js.map +1 -1
- 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 +3 -2
- package/dist/es/standards-sdk.es84.js.map +1 -1
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es152.js","sources":["../../src/services/registry-broker/client/agents.ts"],"sourcesContent":["import type {\n AgentRegistrationRequest,\n DashboardStatsResponse,\n JsonValue,\n RegisterAgentOptions,\n RegisterAgentQuoteResponse,\n RegisterAgentResponse,\n RegistrationProgressRecord,\n RegistrationProgressWaitOptions,\n ResolvedAgentResponse,\n UaidConnectionStatus,\n UaidValidationResponse,\n} from '../types';\nimport {\n dashboardStatsResponseSchema,\n registerAgentResponseSchema,\n registrationProgressResponseSchema,\n registrationQuoteResponseSchema,\n resolveResponseSchema,\n uaidConnectionStatusSchema,\n uaidValidationResponseSchema,\n} from '../schemas';\nimport type { RegistryBrokerClient } from './base-client';\nimport { purchaseCreditsWithHbar } from './credits';\nimport {\n createAbortError,\n DEFAULT_PROGRESS_INTERVAL_MS,\n DEFAULT_PROGRESS_TIMEOUT_MS,\n MINIMUM_REGISTRATION_AUTO_TOP_UP_CREDITS,\n serialiseAgentRegistrationRequest,\n} from './utils';\nimport { RegistryBrokerError } from './errors';\n\nasync function performRegisterAgent(\n client: RegistryBrokerClient,\n payload: AgentRegistrationRequest,\n): Promise<RegisterAgentResponse> {\n const raw = await client.requestJson<JsonValue>('/register', {\n method: 'POST',\n body: serialiseAgentRegistrationRequest(payload),\n headers: { 'content-type': 'application/json' },\n });\n return client.parseWithSchema(\n raw,\n registerAgentResponseSchema,\n 'register agent response',\n );\n}\n\nfunction calculateHbarAmount(\n creditsToPurchase: number,\n creditsPerHbar: number,\n): number {\n if (creditsPerHbar <= 0) {\n throw new Error('creditsPerHbar must be positive');\n }\n if (creditsToPurchase <= 0) {\n throw new Error('creditsToPurchase must be positive');\n }\n const rawHbar = creditsToPurchase / creditsPerHbar;\n const tinybars = Math.ceil(rawHbar * 1e8);\n return tinybars / 1e8;\n}\n\nfunction resolveCreditsToPurchase(shortfallCredits: number): number {\n if (!Number.isFinite(shortfallCredits) || shortfallCredits <= 0) {\n return 0;\n }\n return Math.max(\n Math.ceil(shortfallCredits),\n MINIMUM_REGISTRATION_AUTO_TOP_UP_CREDITS,\n );\n}\n\nasync function ensureCreditsForRegistration(\n client: RegistryBrokerClient,\n payload: AgentRegistrationRequest,\n autoTopUp: RegisterAgentOptions['autoTopUp'],\n): Promise<void> {\n const details = autoTopUp ?? null;\n if (!details) {\n return;\n }\n\n if (!details.accountId || !details.accountId.trim()) {\n throw new Error('autoTopUp.accountId is required');\n }\n\n if (!details.privateKey || !details.privateKey.trim()) {\n throw new Error('autoTopUp.privateKey is required');\n }\n\n for (let attempt = 0; attempt < 3; attempt += 1) {\n const quote = await getRegistrationQuote(client, payload);\n const shortfall = quote.shortfallCredits ?? 0;\n if (shortfall <= 0) {\n return;\n }\n const creditsToPurchase = resolveCreditsToPurchase(shortfall);\n if (creditsToPurchase <= 0) {\n return;\n }\n\n const creditsPerHbar = quote.creditsPerHbar ?? null;\n if (!creditsPerHbar || creditsPerHbar <= 0) {\n throw new Error('Unable to determine credits per HBAR for auto top-up');\n }\n\n const hbarAmount = calculateHbarAmount(creditsToPurchase, creditsPerHbar);\n\n await purchaseCreditsWithHbar(client, {\n accountId: details.accountId.trim(),\n privateKey: details.privateKey.trim(),\n hbarAmount,\n memo: details.memo ?? 'Registry Broker auto top-up',\n metadata: {\n shortfallCredits: shortfall,\n requiredCredits: quote.requiredCredits,\n purchasedCredits: creditsToPurchase,\n },\n });\n }\n\n const finalQuote = await getRegistrationQuote(client, payload);\n if ((finalQuote.shortfallCredits ?? 0) > 0) {\n throw new Error('Unable to purchase sufficient credits for registration');\n }\n}\n\nexport async function resolveUaid(\n client: RegistryBrokerClient,\n uaid: string,\n): Promise<ResolvedAgentResponse> {\n const raw = await client.requestJson<JsonValue>(\n `/resolve/${encodeURIComponent(uaid)}`,\n {\n method: 'GET',\n },\n );\n return client.parseWithSchema(\n raw,\n resolveResponseSchema,\n 'resolve UAID response',\n );\n}\n\nexport async function registerAgent(\n client: RegistryBrokerClient,\n payload: AgentRegistrationRequest,\n options?: RegisterAgentOptions,\n): Promise<RegisterAgentResponse> {\n const autoTopUp = options?.autoTopUp ?? client.registrationAutoTopUp;\n\n if (!autoTopUp) {\n return performRegisterAgent(client, payload);\n }\n\n await ensureCreditsForRegistration(client, payload, autoTopUp);\n\n let retried = false;\n while (true) {\n try {\n return await performRegisterAgent(client, payload);\n } catch (error) {\n const shortfall = client.extractInsufficientCreditsDetails(error);\n if (shortfall && !retried) {\n await ensureCreditsForRegistration(client, payload, autoTopUp);\n retried = true;\n continue;\n }\n throw error;\n }\n }\n}\n\nexport async function getRegistrationQuote(\n client: RegistryBrokerClient,\n payload: AgentRegistrationRequest,\n): Promise<RegisterAgentQuoteResponse> {\n const raw = await client.requestJson<JsonValue>('/register/quote', {\n method: 'POST',\n body: serialiseAgentRegistrationRequest(payload),\n headers: { 'content-type': 'application/json' },\n });\n\n return client.parseWithSchema(\n raw,\n registrationQuoteResponseSchema,\n 'registration quote response',\n );\n}\n\nexport async function updateAgent(\n client: RegistryBrokerClient,\n uaid: string,\n payload: AgentRegistrationRequest,\n): Promise<RegisterAgentResponse> {\n const raw = await client.requestJson<JsonValue>(\n `/register/${encodeURIComponent(uaid)}`,\n {\n method: 'PUT',\n body: serialiseAgentRegistrationRequest(payload),\n headers: { 'content-type': 'application/json' },\n },\n );\n\n return client.parseWithSchema(\n raw,\n registerAgentResponseSchema,\n 'update agent response',\n );\n}\n\nexport async function getRegistrationProgress(\n client: RegistryBrokerClient,\n attemptId: string,\n): Promise<RegistrationProgressRecord | null> {\n const normalisedAttemptId = attemptId.trim();\n if (!normalisedAttemptId) {\n throw new Error('attemptId is required');\n }\n\n try {\n const raw = await client.requestJson<JsonValue>(\n `/register/progress/${encodeURIComponent(normalisedAttemptId)}`,\n { method: 'GET' },\n );\n\n const parsed = client.parseWithSchema(\n raw,\n registrationProgressResponseSchema,\n 'registration progress response',\n );\n\n return parsed.progress;\n } catch (error) {\n if (error instanceof RegistryBrokerError && error.status === 404) {\n return null;\n }\n throw error;\n }\n}\n\nexport async function waitForRegistrationCompletion(\n client: RegistryBrokerClient,\n attemptId: string,\n options: RegistrationProgressWaitOptions = {},\n): Promise<RegistrationProgressRecord> {\n const normalisedAttemptId = attemptId.trim();\n if (!normalisedAttemptId) {\n throw new Error('attemptId is required');\n }\n\n const interval = Math.max(\n 250,\n options.intervalMs ?? DEFAULT_PROGRESS_INTERVAL_MS,\n );\n const timeoutMs = options.timeoutMs ?? DEFAULT_PROGRESS_TIMEOUT_MS;\n const throwOnFailure = options.throwOnFailure ?? true;\n const signal = options.signal;\n const startedAt = Date.now();\n\n while (true) {\n if (signal?.aborted) {\n throw createAbortError();\n }\n\n const progress = await client.getRegistrationProgress(normalisedAttemptId);\n\n if (progress) {\n options.onProgress?.(progress);\n\n if (progress.status === 'completed') {\n return progress;\n }\n\n if (progress.status === 'partial' || progress.status === 'failed') {\n if (throwOnFailure) {\n throw new RegistryBrokerError(\n 'Registration did not complete successfully',\n {\n status: 409,\n statusText: progress.status,\n body: progress,\n },\n );\n }\n return progress;\n }\n }\n\n if (Date.now() - startedAt >= timeoutMs) {\n throw new Error(\n `Registration progress polling timed out after ${timeoutMs}ms`,\n );\n }\n\n await client.delay(interval, signal);\n }\n}\n\nexport async function validateUaid(\n client: RegistryBrokerClient,\n uaid: string,\n): Promise<UaidValidationResponse> {\n const raw = await client.requestJson<JsonValue>(\n `/uaids/validate/${encodeURIComponent(uaid)}`,\n {\n method: 'GET',\n },\n );\n return client.parseWithSchema(\n raw,\n uaidValidationResponseSchema,\n 'UAID validation response',\n );\n}\n\nexport async function getUaidConnectionStatus(\n client: RegistryBrokerClient,\n uaid: string,\n): Promise<UaidConnectionStatus> {\n const raw = await client.requestJson<JsonValue>(\n `/uaids/connections/${encodeURIComponent(uaid)}/status`,\n {\n method: 'GET',\n },\n );\n return client.parseWithSchema(\n raw,\n uaidConnectionStatusSchema,\n 'UAID connection status',\n );\n}\n\nexport async function closeUaidConnection(\n client: RegistryBrokerClient,\n uaid: string,\n): Promise<void> {\n await client.request(`/uaids/connections/${encodeURIComponent(uaid)}`, {\n method: 'DELETE',\n });\n}\n\nexport async function dashboardStats(\n client: RegistryBrokerClient,\n): Promise<DashboardStatsResponse> {\n const raw = await client.requestJson<JsonValue>('/dashboard/stats', {\n method: 'GET',\n });\n return client.parseWithSchema(\n raw,\n dashboardStatsResponseSchema,\n 'dashboard stats response',\n );\n}\n"],"names":[],"mappings":";;;;AAiCA,eAAe,qBACb,QACA,SACgC;AAChC,QAAM,MAAM,MAAM,OAAO,YAAuB,aAAa;AAAA,IAC3D,QAAQ;AAAA,IACR,MAAM,kCAAkC,OAAO;AAAA,IAC/C,SAAS,EAAE,gBAAgB,mBAAA;AAAA,EAAmB,CAC/C;AACD,SAAO,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEA,SAAS,oBACP,mBACA,gBACQ;AACR,MAAI,kBAAkB,GAAG;AACvB,UAAM,IAAI,MAAM,iCAAiC;AAAA,EACnD;AACA,MAAI,qBAAqB,GAAG;AAC1B,UAAM,IAAI,MAAM,oCAAoC;AAAA,EACtD;AACA,QAAM,UAAU,oBAAoB;AACpC,QAAM,WAAW,KAAK,KAAK,UAAU,GAAG;AACxC,SAAO,WAAW;AACpB;AAEA,SAAS,yBAAyB,kBAAkC;AAClE,MAAI,CAAC,OAAO,SAAS,gBAAgB,KAAK,oBAAoB,GAAG;AAC/D,WAAO;AAAA,EACT;AACA,SAAO,KAAK;AAAA,IACV,KAAK,KAAK,gBAAgB;AAAA,IAC1B;AAAA,E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AAW;AACvC,YAAM,IAAI;AAAA,QACR,iDAAiD,SAAS;AAAA,MAAA;AAAA,IAE9D;AAEA,UAAM,OAAO,MAAM,UAAU,MAAM;AAAA,EACrC;AACF;AAEA,eAAsB,aACpB,QACA,MACiC;AACjC,QAAM,MAAM,MAAM,OAAO;AAAA,IACvB,mBAAmB,mBAAmB,IAAI,CAAC;AAAA,IAC3C;AAAA,MACE,QAAQ;AAAA,IAAA;AAAA,EACV;AAEF,SAAO,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEA,eAAsB,wBACpB,QACA,MAC+B;AAC/B,QAAM,MAAM,MAAM,OAAO;AAAA,IACvB,sBAAsB,mBAAmB,IAAI,CAAC;AAAA,IAC9C;AAAA,MACE,QAAQ;AAAA,IAAA;AAAA,EACV;AAEF,SAAO,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;AAEA,eAAsB,oBACpB,QACA,MACe;AACf,QAAM,OAAO,QAAQ,sBAAsB,mBAAmB,IAAI,CAAC,IAAI;AAAA,IACrE,QAAQ;AAAA,EAAA,CACT;AACH;AAEA,eAAsB,eACpB,QACiC;AACjC,QAAM,MAAM,MAAM,OAAO,YAAuB,oBAAoB;AAAA,IAClE,QAAQ;AAAA,EAAA,CACT;AACD,SAAO,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es152.js","sources":["../../src/services/registry-broker/client/agent-network.ts"],"sourcesContent":["/**\n * Agent-network client surface — typed methods over the registry-broker\n * /api/v1/agent-* routes. Two auth planes:\n *\n * - Owner plane uses the client's configured credentials (x-api-key).\n * - Bot plane takes a `hol_agt_…` grant bearer token per call; the token is\n * passed as Authorization and never persisted by the client.\n *\n * Every response is parsed with the schemas below so pending/terminal\n * discriminated states survive to callers. Idempotency keys, lease versions\n * (fencing tokens), and cancellation ids are passed through unchanged.\n */\nimport { z } from 'zod';\nimport type { RegistryBrokerClient } from './base-client';\nimport { RegistryBrokerParseError } from './errors';\nimport type { JsonValue } from '../types';\n\n// ---------------------------------------------------------------------------\n// Schemas (mirror broker contract)\n// ---------------------------------------------------------------------------\n\nexport const agentNetworkProviderSchema = z.enum([\n 'openclaw',\n 'grok',\n 'dot',\n 'muse',\n 'api',\n 'other',\n]);\nexport type AgentNetworkProvider = z.infer<typeof agentNetworkProviderSchema>;\n\nexport const agentConnectionStateSchema = z.enum([\n 'unavailable',\n 'pending_pairing',\n 'interactive_verified',\n 'polling_verified',\n 'push_verified',\n 'needs_reconnect',\n 'paused',\n 'degraded',\n]);\n\nexport const agentRegistrationStateSchema = z.enum([\n 'unregistered',\n 'quote_issued',\n 'pending',\n 'registered',\n 'failed',\n]);\n\n/**\n * The registration *result* enum is distinct from the persisted lifecycle\n * state — a register call resolves to one of these, including `linked` for\n * owners attaching an existing UAID.\n */\nexport const agentRegistrationResultStateSchema = z.enum([\n 'registered',\n 'pending',\n 'linked',\n 'unregistered',\n]);\n\nexport const agentReceiveModeSchema = z.enum(['none', 'poll', 'push']);\n\nexport const agentRequestStateSchema = z.enum([\n 'accepted',\n 'awaiting_consent',\n 'queued',\n 'processing',\n 'completed',\n 'rejected',\n 'failed',\n 'expired',\n 'canceled',\n]);\nexport type AgentRequestState = z.infer<typeof agentRequestStateSchema>;\n\nexport const agentDeliveryStateSchema = z.enum([\n 'pending',\n 'notifying',\n 'provider_accepted',\n 'acknowledged',\n 'retry_scheduled',\n 'permanently_failed',\n]);\nexport type AgentDeliveryState = z.infer<typeof agentDeliveryStateSchema>;\n\nexport const agentMessageKindSchema = z.enum(['request', 'response', 'event']);\nexport type AgentMessageKind = z.infer<typeof agentMessageKindSchema>;\n\nconst isoDate = z.string();\n\nexport const agentRuntimeViewSchema = z.object({\n runtimeId: z.string().uuid(),\n uaid: z.string().nullable(),\n ownerType: z.string(),\n ownerId: z.string(),\n declaredProvider: agentNetworkProviderSchema,\n connectionState: agentConnectionStateSchema,\n registrationState: agentRegistrationStateSchema,\n registrationAttemptId: z.string().nullable(),\n receiveMode: agentReceiveModeSchema,\n gatewayUrl: z.string().nullable(),\n paused: z.boolean(),\n allowedPeerUaids: z.array(z.string()).nullable(),\n capabilities: z.array(z.string()),\n lastActivityAt: isoDate.nullable(),\n createdAt: isoDate,\n});\nexport type AgentRuntimeView = z.infer<typeof agentRuntimeViewSchema>;\n\nexport const agentRuntimeQuoteSchema = z.object({\n quoteId: z.string(),\n expiresAt: isoDate,\n registrationFeeCredits: z.number().nullable(),\n gatewayUrl: z.string(),\n});\nexport type AgentRuntimeQuote = z.infer<typeof agentRuntimeQuoteSchema>;\n\nexport const agentPairingStartSchema = z.object({\n grantId: z.string().uuid(),\n pairingCode: z.string(),\n expiresAt: isoDate,\n});\nexport type AgentPairingStart = z.infer<typeof agentPairingStartSchema>;\n\nexport const agentPairingCompleteSchema = z.object({\n grantId: z.string().uuid(),\n runtimeId: z.string().uuid(),\n token: z.string(),\n scopes: z.array(z.string()),\n});\nexport type AgentPairingComplete = z.infer<typeof agentPairingCompleteSchema>;\n\nexport const agentMessageViewSchema = z.object({\n messageId: z.string().uuid(),\n conversationId: z.string().uuid(),\n schemaVersion: z.literal('hol-agent-message/1'),\n kind: agentMessageKindSchema,\n senderUaid: z.string(),\n recipientUaid: z.string(),\n inReplyTo: z.string().uuid().nullable(),\n content: z.object({ type: z.literal('text'), text: z.string() }),\n requestState: agentRequestStateSchema,\n createdAt: isoDate,\n expiresAt: isoDate,\n traceId: z.string(),\n});\nexport type AgentMessageView = z.infer<typeof agentMessageViewSchema>;\n\nexport const agentMessageAcceptedSchema = z.object({\n messageId: z.string().uuid(),\n conversationId: z.string().uuid(),\n requestState: agentRequestStateSchema,\n createdAt: isoDate,\n expiresAt: isoDate,\n deduplicated: z.boolean(),\n});\nexport type AgentMessageAccepted = z.infer<typeof agentMessageAcceptedSchema>;\n\nexport const agentLeaseViewSchema = z.object({\n leaseId: z.string().uuid(),\n messageId: z.string().uuid(),\n fencingToken: z.number().int(),\n expiresAt: isoDate,\n});\nexport type AgentLeaseView = z.infer<typeof agentLeaseViewSchema>;\n\nexport const agentClaimedMessageSchema = z.object({\n message: agentMessageViewSchema,\n lease: agentLeaseViewSchema,\n});\nexport type AgentClaimedMessage = z.infer<typeof agentClaimedMessageSchema>;\n\nexport const agentInboxItemSchema = z.object({\n messageId: z.string().uuid(),\n conversationId: z.string().uuid(),\n kind: agentMessageKindSchema,\n senderUaid: z.string(),\n content: z.object({ type: z.literal('text'), text: z.string() }),\n requestState: agentRequestStateSchema,\n deliveryState: agentDeliveryStateSchema,\n acknowledged: z.boolean(),\n leaseId: z.string().uuid().nullable(),\n fencingToken: z.number().int().nullable(),\n createdAt: isoDate,\n expiresAt: isoDate,\n});\nexport type AgentInboxItem = z.infer<typeof agentInboxItemSchema>;\n\nexport const agentInboxListSchema = z.object({\n items: z.array(agentInboxItemSchema),\n nextCursor: z.string().nullable(),\n});\nexport type AgentInboxList = z.infer<typeof agentInboxListSchema>;\n\nexport const agentConversationViewSchema = z.object({\n conversationId: z.string().uuid(),\n state: z.enum(['active', 'canceled', 'expired']),\n participants: z.array(z.object({ uaid: z.string() })),\n messages: z.array(agentMessageViewSchema),\n nextCursor: z.string().nullable(),\n});\nexport type AgentConversationView = z.infer<typeof agentConversationViewSchema>;\n\nexport const agentReplyResultSchema = z.object({\n request: agentMessageViewSchema,\n response: agentMessageViewSchema,\n});\nexport type AgentReplyResult = z.infer<typeof agentReplyResultSchema>;\n\nexport const agentRuntimeRegistrationResultSchema = z.object({\n runtime: agentRuntimeViewSchema,\n registration: agentRegistrationResultStateSchema,\n});\nexport type AgentRuntimeRegistrationResult = z.infer<\n typeof agentRuntimeRegistrationResultSchema\n>;\n\nexport const agentProbeResultSchema = z.object({\n nonce: z.string(),\n issuedAt: isoDate,\n});\n\nexport const agentSubscriptionEventTypeSchema = z.enum([\n 'notify_request',\n 'notify_event',\n 'notify_response',\n]);\nexport type AgentSubscriptionEventType = z.infer<\n typeof agentSubscriptionEventTypeSchema\n>;\n\nexport const agentSubscriptionViewSchema = z.object({\n subscriptionId: z.string().uuid(),\n runtimeId: z.string().uuid(),\n eventType: agentSubscriptionEventTypeSchema,\n callbackUrl: z.string().nullable(),\n state: z.string(),\n expiresAt: isoDate.nullable(),\n createdAt: isoDate,\n});\nexport type AgentSubscriptionView = z.infer<typeof agentSubscriptionViewSchema>;\n\nexport const agentSubscriptionListSchema = z.object({\n subscriptions: z.array(agentSubscriptionViewSchema),\n});\n\nexport const agentSubscriptionCreatedSchema = z.object({\n subscription: agentSubscriptionViewSchema,\n});\n\n// ---------------------------------------------------------------------------\n// Inputs\n// ---------------------------------------------------------------------------\n\nexport interface RegisterAgentRuntimeInput {\n displayName: string;\n declaredProvider: AgentNetworkProvider;\n description?: string;\n capabilities?: string[];\n linkExistingUaid?: string;\n preferredReceiveMode?: 'poll' | 'push';\n}\n\nexport interface UpdateAgentRuntimePolicyInput {\n paused?: boolean;\n allowedPeerUaids?: string[];\n maxOutboundPerMinute?: number;\n maxPendingMessages?: number;\n receiveMode?: 'poll' | 'push';\n}\n\nexport interface SendAgentMessageInput {\n recipientUaid: string;\n conversationId?: string;\n kind: 'request' | 'event';\n content: { type: 'text'; text: string };\n expiresInSeconds?: number;\n /** Caller-generated dedupe key — passed through unchanged. */\n idempotencyKey: string;\n}\n\nexport interface AgentLeaseRef {\n leaseId: string;\n fencingToken: number;\n}\n\nexport interface ReplyToAgentMessageInput extends AgentLeaseRef {\n content: { type: 'text'; text: string };\n idempotencyKey: string;\n outcome?: 'answered' | 'partial' | 'refused';\n}\n\nexport interface AgentInboxQuery {\n cursor?: string;\n limit?: number;\n includeAcknowledged?: boolean;\n}\n\nexport interface CreateAgentSubscriptionInput {\n eventType?: AgentSubscriptionEventType;\n /** Public HTTPS webhook target — validated for safety server-side. */\n callbackUrl: string;\n signingSecret?: string;\n expiresAt?: string;\n}\n\nexport interface WaitForAgentReplyOptions {\n /** Absolute bound — never resends the request. Default 60s. */\n timeoutMs?: number;\n pollIntervalMs?: number;\n signal?: AbortSignal;\n}\n\n// ---------------------------------------------------------------------------\n// API\n// ---------------------------------------------------------------------------\n\nconst sleep = (ms: number, signal?: AbortSignal): Promise<void> =>\n new Promise((resolve, reject) => {\n const t = setTimeout(resolve, ms);\n signal?.addEventListener(\n 'abort',\n () => {\n clearTimeout(t);\n reject(new Error('waitForReply aborted'));\n },\n { once: true },\n );\n });\n\nexport interface RegistryBrokerAgentNetworkApi {\n // --- owner plane (client credentials) ---\n quoteRuntime(): Promise<AgentRuntimeQuote>;\n registerRuntime(\n input: RegisterAgentRuntimeInput,\n ): Promise<AgentRuntimeRegistrationResult>;\n listRuntimes(): Promise<AgentRuntimeView[]>;\n updateRuntimePolicy(\n runtimeId: string,\n input: UpdateAgentRuntimePolicyInput,\n ): Promise<AgentRuntimeView>;\n probeRuntime(runtimeId: string): Promise<{ nonce: string; issuedAt: string }>;\n startAgentConnection(runtimeId: string): Promise<AgentPairingStart>;\n completeAgentPairing(pairingCode: string): Promise<AgentPairingComplete>;\n revokeAgentConnection(grantId: string): Promise<void>;\n /** Owner-scoped inbox read — no bot grant token required. */\n listRuntimeInbox(\n runtimeId: string,\n query?: AgentInboxQuery,\n ): Promise<AgentInboxList>;\n /** Owner-scoped conversation read scoped to an owned runtime. */\n getRuntimeConversation(\n runtimeId: string,\n conversationId: string,\n query?: { cursor?: string; limit?: number },\n ): Promise<AgentConversationView>;\n createAgentSubscription(\n runtimeId: string,\n input: CreateAgentSubscriptionInput,\n ): Promise<AgentSubscriptionView>;\n listAgentSubscriptions(\n runtimeId: string,\n ): Promise<AgentSubscriptionView[]>;\n revokeAgentSubscription(\n runtimeId: string,\n subscriptionId: string,\n ): Promise<void>;\n\n // --- bot plane (grant bearer token) ---\n agentMe(token: string): Promise<AgentRuntimeView>;\n sendAgentMessage(\n token: string,\n input: SendAgentMessageInput,\n ): Promise<AgentMessageAccepted>;\n getAgentMessage(token: string, messageId: string): Promise<AgentMessageView>;\n getAgentConversation(\n token: string,\n conversationId: string,\n query?: { cursor?: string; limit?: number },\n ): Promise<AgentConversationView>;\n listAgentInbox(\n token: string,\n query?: AgentInboxQuery,\n ): Promise<AgentInboxList>;\n claimAgentMessage(token: string): Promise<AgentClaimedMessage | null>;\n acknowledgeAgentMessage(\n token: string,\n messageId: string,\n lease: AgentLeaseRef,\n ): Promise<AgentMessageView>;\n renewAgentMessageLease(\n token: string,\n messageId: string,\n lease: AgentLeaseRef & { extendSeconds?: number },\n ): Promise<AgentLeaseView>;\n replyToAgentMessage(\n token: string,\n messageId: string,\n input: ReplyToAgentMessageInput,\n ): Promise<AgentReplyResult>;\n rejectAgentMessage(\n token: string,\n messageId: string,\n lease: AgentLeaseRef & { reason?: string },\n ): Promise<AgentMessageView>;\n cancelAgentConversation(\n token: string,\n conversationId: string,\n ): Promise<{ conversationId: string; canceledMessages: number }>;\n /**\n * Bounded wait for a reply — polls status without resending. Returns the\n * response message when the request completes, null on timeout.\n */\n waitForAgentReply(\n token: string,\n messageId: string,\n options?: WaitForAgentReplyOptions,\n ): Promise<AgentMessageView | null>;\n}\n\nconst bearerHeaders = (token: string): Record<string, string> => ({\n authorization: `Bearer ${token}`,\n});\n\nconst encodePath = (value: string): string => encodeURIComponent(value);\n\nconst qs = (params: Record<string, string | number | boolean | undefined>) => {\n const query = new URLSearchParams();\n for (const [k, v] of Object.entries(params)) {\n if (v !== undefined) {\n query.set(k, String(v));\n }\n }\n const s = query.toString();\n return s ? `?${s}` : '';\n};\n\nexport function createAgentNetworkApi(\n client: RegistryBrokerClient,\n): RegistryBrokerAgentNetworkApi {\n const json = async <S extends z.ZodTypeAny>(\n path: string,\n schema: S,\n init: { method?: string; body?: unknown; token?: string },\n ): Promise<z.infer<S>> => {\n const raw = await client.requestJson<JsonValue>(`${path}`, {\n method: init.method ?? 'GET',\n body: init.body as JsonValue,\n headers: init.token ? bearerHeaders(init.token) : undefined,\n });\n const parsed = schema.safeParse(raw);\n if (!parsed.success) {\n throw new RegistryBrokerParseError(\n 'Unexpected agent-network response shape',\n JSON.stringify(raw).slice(0, 500),\n );\n }\n return parsed.data;\n };\n\n const bot204 = async (path: string, token: string, body?: unknown) => {\n const response = await client.request(`${path}`, {\n method: 'POST',\n body,\n headers: bearerHeaders(token),\n });\n return response.status === 204 ? null : response.json();\n };\n\n return {\n quoteRuntime: () =>\n json('/agent-runtimes/quote', agentRuntimeQuoteSchema, {\n method: 'POST',\n }),\n\n registerRuntime: (input) =>\n json('/agent-runtimes/register', agentRuntimeRegistrationResultSchema, {\n method: 'POST',\n body: input,\n }),\n\n listRuntimes: async () => {\n const raw = await client.requestJson<JsonValue>('/agent-runtimes', {});\n const parsed = z\n .object({ runtimes: z.array(agentRuntimeViewSchema) })\n .safeParse(raw);\n if (!parsed.success) {\n throw new RegistryBrokerParseError(\n 'Unexpected runtime list shape',\n JSON.stringify(raw).slice(0, 500),\n );\n }\n return parsed.data.runtimes;\n },\n\n updateRuntimePolicy: (runtimeId, input) =>\n json(\n `/agent-runtimes/${encodePath(runtimeId)}`,\n agentRuntimeViewSchema,\n { method: 'PATCH', body: input },\n ),\n\n probeRuntime: async (runtimeId) =>\n (await json(\n `/agent-runtimes/${encodePath(runtimeId)}/probe`,\n agentProbeResultSchema,\n { method: 'POST' },\n )) as { nonce: string; issuedAt: string },\n\n startAgentConnection: (runtimeId) =>\n json('/agent-connections', agentPairingStartSchema, {\n method: 'POST',\n body: { runtimeId },\n }),\n\n completeAgentPairing: (pairingCode) =>\n json('/agent-connections/pair', agentPairingCompleteSchema, {\n method: 'POST',\n body: { pairingCode },\n }),\n\n revokeAgentConnection: async (grantId) => {\n await client.request(`/agent-connections/${encodePath(grantId)}`, {\n method: 'DELETE',\n });\n },\n\n listRuntimeInbox: (runtimeId, query) =>\n json(\n `/agent-runtimes/${encodePath(runtimeId)}/inbox${qs({\n cursor: query?.cursor,\n limit: query?.limit,\n includeAcknowledged: query?.includeAcknowledged,\n })}`,\n agentInboxListSchema,\n {},\n ),\n\n getRuntimeConversation: (runtimeId, conversationId, query) =>\n json(\n `/agent-runtimes/${encodePath(runtimeId)}/conversations/${encodePath(\n conversationId,\n )}${qs({ cursor: query?.cursor, limit: query?.limit })}`,\n agentConversationViewSchema,\n {},\n ),\n\n createAgentSubscription: async (runtimeId, input) =>\n (\n await json(\n `/agent-runtimes/${encodePath(runtimeId)}/subscriptions`,\n agentSubscriptionCreatedSchema,\n { method: 'POST', body: input },\n )\n ).subscription,\n\n listAgentSubscriptions: async (runtimeId) =>\n (\n await json(\n `/agent-runtimes/${encodePath(runtimeId)}/subscriptions`,\n agentSubscriptionListSchema,\n {},\n )\n ).subscriptions,\n\n revokeAgentSubscription: async (runtimeId, subscriptionId) => {\n await client.request(\n `/agent-runtimes/${encodePath(runtimeId)}/subscriptions/${encodePath(\n subscriptionId,\n )}`,\n { method: 'DELETE' },\n );\n },\n\n agentMe: async (token) => {\n const raw = await client.requestJson<JsonValue>(\n '/agent-runtimes/me',\n { headers: bearerHeaders(token) },\n );\n const parsed = z\n .object({ runtime: agentRuntimeViewSchema })\n .safeParse(raw);\n if (!parsed.success) {\n throw new RegistryBrokerParseError(\n 'Unexpected agent-runtimes/me shape',\n JSON.stringify(raw).slice(0, 500),\n );\n }\n return parsed.data.runtime;\n },\n\n sendAgentMessage: (token, input) =>\n json('/agent-messages', agentMessageAcceptedSchema, {\n method: 'POST',\n body: input,\n token,\n }),\n\n getAgentMessage: (token, messageId) =>\n json(\n `/agent-messages/${encodePath(messageId)}`,\n agentMessageViewSchema,\n { token },\n ),\n\n getAgentConversation: (token, conversationId, query) =>\n json(\n `/agent-conversations/${encodePath(conversationId)}${qs({\n cursor: query?.cursor,\n limit: query?.limit,\n })}`,\n agentConversationViewSchema,\n { token },\n ),\n\n listAgentInbox: (token, query) =>\n json(\n `/agent-inbox${qs({\n cursor: query?.cursor,\n limit: query?.limit,\n includeAcknowledged: query?.includeAcknowledged,\n })}`,\n agentInboxListSchema,\n { token },\n ),\n\n claimAgentMessage: async (token) => {\n const raw = await bot204('/agent-inbox/leases', token, {});\n if (raw === null) {\n return null;\n }\n const parsed = agentClaimedMessageSchema.safeParse(raw);\n if (!parsed.success) {\n throw new RegistryBrokerParseError(\n 'Unexpected claim response shape',\n JSON.stringify(raw).slice(0, 500),\n );\n }\n return parsed.data;\n },\n\n acknowledgeAgentMessage: (token, messageId, lease) =>\n json(\n `/agent-inbox/${encodePath(messageId)}/ack`,\n agentMessageViewSchema,\n { method: 'POST', body: lease, token },\n ),\n\n renewAgentMessageLease: (token, messageId, input) =>\n json(\n `/agent-inbox/${encodePath(messageId)}/lease/renew`,\n agentLeaseViewSchema,\n { method: 'POST', body: input, token },\n ),\n\n replyToAgentMessage: (token, messageId, input) =>\n json(\n `/agent-messages/${encodePath(messageId)}/reply`,\n agentReplyResultSchema,\n { method: 'POST', body: input, token },\n ),\n\n rejectAgentMessage: (token, messageId, input) =>\n json(\n `/agent-messages/${encodePath(messageId)}/reject`,\n agentMessageViewSchema,\n { method: 'POST', body: input, token },\n ),\n\n cancelAgentConversation: async (token, conversationId) => {\n const raw = await client.requestJson<JsonValue>(\n `/agent-conversations/${encodePath(conversationId)}/cancel`,\n { method: 'POST', body: {}, headers: bearerHeaders(token) },\n );\n const parsed = z\n .object({\n conversationId: z.string().uuid(),\n canceledMessages: z.number(),\n })\n .safeParse(raw);\n if (!parsed.success) {\n throw new RegistryBrokerParseError(\n 'Unexpected cancel response shape',\n JSON.stringify(raw).slice(0, 500),\n );\n }\n return parsed.data as {\n conversationId: string;\n canceledMessages: number;\n };\n },\n\n waitForAgentReply: async (token, messageId, options) => {\n const timeoutMs = options?.timeoutMs ?? 60_000;\n const interval = Math.max(250, options?.pollIntervalMs ?? 2_000);\n const deadline = Date.now() + timeoutMs;\n while (Date.now() < deadline) {\n const message = await json(\n `/agent-messages/${encodePath(messageId)}`,\n agentMessageViewSchema,\n { token },\n );\n if (message.requestState === 'completed') {\n const conversation = await json(\n `/agent-conversations/${encodePath(message.conversationId)}`,\n agentConversationViewSchema,\n { token },\n );\n return (\n conversation.messages.find(\n (m) => m.inReplyTo === messageId && m.kind === 'response',\n ) ?? null\n );\n }\n if (\n message.requestState === 'rejected' ||\n message.requestState === 'failed' ||\n message.requestState === 'expired' ||\n message.requestState === 'canceled'\n ) {\n return null;\n }\n await sleep(Math.min(interval, deadline - Date.now()), options?.signal);\n }\n return null;\n },\n };\n}\n"],"names":[],"mappings":";;AAqBO,MAAM,6BAA6B,EAAE,KAAK;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,MAAM,6BAA6B,EAAE,KAAK;AAAA,EAC/C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,MAAM,+BAA+B,EAAE,KAAK;AAAA,EACjD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAOM,MAAM,qCAAqC,EAAE,KAAK;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAEM,MAAM,yBAAyB,EAAE,KAAK,CAAC,QAAQ,QAAQ,MAAM,CAAC;AAE9D,MAAM,0BAA0B,EAAE,KAAK;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,MAAM,2BAA2B,EAAE,KAAK;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,MAAM,yBAAyB,EAAE,KAAK,CAAC,WAAW,YAAY,OAAO,CAAC;AAG7E,MAAM,UAAU,EAAE,OAAA;AAEX,MAAM,yBAAyB,EAAE,OAAO;AAAA,EAC7C,WAAW,EAAE,OAAA,EAAS,KAAA;AAAA,EACtB,MAAM,EAAE,OAAA,EAAS,SAAA;AAAA,E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A,EAAE,MAAA;AAAA,QAAM;AAEV,YAAI,QAAQ,iBAAiB,aAAa;AACxC,gBAAM,eAAe,MAAM;AAAA,YACzB,wBAAwB,WAAW,QAAQ,cAAc,CAAC;AAAA,YAC1D;AAAA,YACA,EAAE,MAAA;AAAA,UAAM;AAEV,iBACE,aAAa,SAAS;AAAA,YACpB,CAAC,MAAM,EAAE,cAAc,aAAa,EAAE,SAAS;AAAA,UAAA,KAC5C;AAAA,QAET;AACA,YACE,QAAQ,iBAAiB,cACzB,QAAQ,iBAAiB,YACzB,QAAQ,iBAAiB,aACzB,QAAQ,iBAAiB,YACzB;AACA,iBAAO;AAAA,QACT;AACA,cAAM,MAAM,KAAK,IAAI,UAAU,WAAW,KAAK,IAAA,CAAK,GAAG,SAAS,MAAM;AAAA,MACxE;AACA,aAAO;AAAA,IACT;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,7 +1,262 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { dashboardStatsResponseSchema, registrationProgressResponseSchema, registrationQuoteResponseSchema, uaidConnectionStatusSchema, resolveResponseSchema, registerAgentResponseSchema, uaidValidationResponseSchema } from "./standards-sdk.es158.js";
|
|
2
|
+
import { purchaseCreditsWithHbar } from "./standards-sdk.es205.js";
|
|
3
|
+
import { serialiseAgentRegistrationRequest, DEFAULT_PROGRESS_INTERVAL_MS, DEFAULT_PROGRESS_TIMEOUT_MS, createAbortError, MINIMUM_REGISTRATION_AUTO_TOP_UP_CREDITS } from "./standards-sdk.es209.js";
|
|
4
|
+
import { RegistryBrokerError } from "./standards-sdk.es151.js";
|
|
5
|
+
async function performRegisterAgent(client, payload) {
|
|
6
|
+
const raw = await client.requestJson("/register", {
|
|
7
|
+
method: "POST",
|
|
8
|
+
body: serialiseAgentRegistrationRequest(payload),
|
|
9
|
+
headers: { "content-type": "application/json" }
|
|
10
|
+
});
|
|
11
|
+
return client.parseWithSchema(
|
|
12
|
+
raw,
|
|
13
|
+
registerAgentResponseSchema,
|
|
14
|
+
"register agent response"
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
function calculateHbarAmount(creditsToPurchase, creditsPerHbar) {
|
|
18
|
+
if (creditsPerHbar <= 0) {
|
|
19
|
+
throw new Error("creditsPerHbar must be positive");
|
|
20
|
+
}
|
|
21
|
+
if (creditsToPurchase <= 0) {
|
|
22
|
+
throw new Error("creditsToPurchase must be positive");
|
|
23
|
+
}
|
|
24
|
+
const rawHbar = creditsToPurchase / creditsPerHbar;
|
|
25
|
+
const tinybars = Math.ceil(rawHbar * 1e8);
|
|
26
|
+
return tinybars / 1e8;
|
|
27
|
+
}
|
|
28
|
+
function resolveCreditsToPurchase(shortfallCredits) {
|
|
29
|
+
if (!Number.isFinite(shortfallCredits) || shortfallCredits <= 0) {
|
|
30
|
+
return 0;
|
|
31
|
+
}
|
|
32
|
+
return Math.max(
|
|
33
|
+
Math.ceil(shortfallCredits),
|
|
34
|
+
MINIMUM_REGISTRATION_AUTO_TOP_UP_CREDITS
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
async function ensureCreditsForRegistration(client, payload, autoTopUp) {
|
|
38
|
+
const details = autoTopUp ?? null;
|
|
39
|
+
if (!details) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!details.accountId || !details.accountId.trim()) {
|
|
43
|
+
throw new Error("autoTopUp.accountId is required");
|
|
44
|
+
}
|
|
45
|
+
if (!details.privateKey || !details.privateKey.trim()) {
|
|
46
|
+
throw new Error("autoTopUp.privateKey is required");
|
|
47
|
+
}
|
|
48
|
+
for (let attempt = 0; attempt < 3; attempt += 1) {
|
|
49
|
+
const quote = await getRegistrationQuote(client, payload);
|
|
50
|
+
const shortfall = quote.shortfallCredits ?? 0;
|
|
51
|
+
if (shortfall <= 0) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const creditsToPurchase = resolveCreditsToPurchase(shortfall);
|
|
55
|
+
if (creditsToPurchase <= 0) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const creditsPerHbar = quote.creditsPerHbar ?? null;
|
|
59
|
+
if (!creditsPerHbar || creditsPerHbar <= 0) {
|
|
60
|
+
throw new Error("Unable to determine credits per HBAR for auto top-up");
|
|
61
|
+
}
|
|
62
|
+
const hbarAmount = calculateHbarAmount(creditsToPurchase, creditsPerHbar);
|
|
63
|
+
await purchaseCreditsWithHbar(client, {
|
|
64
|
+
accountId: details.accountId.trim(),
|
|
65
|
+
privateKey: details.privateKey.trim(),
|
|
66
|
+
hbarAmount,
|
|
67
|
+
memo: details.memo ?? "Registry Broker auto top-up",
|
|
68
|
+
metadata: {
|
|
69
|
+
shortfallCredits: shortfall,
|
|
70
|
+
requiredCredits: quote.requiredCredits,
|
|
71
|
+
purchasedCredits: creditsToPurchase
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
const finalQuote = await getRegistrationQuote(client, payload);
|
|
76
|
+
if ((finalQuote.shortfallCredits ?? 0) > 0) {
|
|
77
|
+
throw new Error("Unable to purchase sufficient credits for registration");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async function resolveUaid(client, uaid) {
|
|
81
|
+
const raw = await client.requestJson(
|
|
82
|
+
`/resolve/${encodeURIComponent(uaid)}`,
|
|
83
|
+
{
|
|
84
|
+
method: "GET"
|
|
85
|
+
}
|
|
86
|
+
);
|
|
87
|
+
return client.parseWithSchema(
|
|
88
|
+
raw,
|
|
89
|
+
resolveResponseSchema,
|
|
90
|
+
"resolve UAID response"
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
async function registerAgent(client, payload, options) {
|
|
94
|
+
const autoTopUp = options?.autoTopUp ?? client.registrationAutoTopUp;
|
|
95
|
+
if (!autoTopUp) {
|
|
96
|
+
return performRegisterAgent(client, payload);
|
|
97
|
+
}
|
|
98
|
+
await ensureCreditsForRegistration(client, payload, autoTopUp);
|
|
99
|
+
let retried = false;
|
|
100
|
+
while (true) {
|
|
101
|
+
try {
|
|
102
|
+
return await performRegisterAgent(client, payload);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
const shortfall = client.extractInsufficientCreditsDetails(error);
|
|
105
|
+
if (shortfall && !retried) {
|
|
106
|
+
await ensureCreditsForRegistration(client, payload, autoTopUp);
|
|
107
|
+
retried = true;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
async function getRegistrationQuote(client, payload) {
|
|
115
|
+
const raw = await client.requestJson("/register/quote", {
|
|
116
|
+
method: "POST",
|
|
117
|
+
body: serialiseAgentRegistrationRequest(payload),
|
|
118
|
+
headers: { "content-type": "application/json" }
|
|
119
|
+
});
|
|
120
|
+
return client.parseWithSchema(
|
|
121
|
+
raw,
|
|
122
|
+
registrationQuoteResponseSchema,
|
|
123
|
+
"registration quote response"
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
async function updateAgent(client, uaid, payload) {
|
|
127
|
+
const raw = await client.requestJson(
|
|
128
|
+
`/register/${encodeURIComponent(uaid)}`,
|
|
129
|
+
{
|
|
130
|
+
method: "PUT",
|
|
131
|
+
body: serialiseAgentRegistrationRequest(payload),
|
|
132
|
+
headers: { "content-type": "application/json" }
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
return client.parseWithSchema(
|
|
136
|
+
raw,
|
|
137
|
+
registerAgentResponseSchema,
|
|
138
|
+
"update agent response"
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
async function getRegistrationProgress(client, attemptId) {
|
|
142
|
+
const normalisedAttemptId = attemptId.trim();
|
|
143
|
+
if (!normalisedAttemptId) {
|
|
144
|
+
throw new Error("attemptId is required");
|
|
145
|
+
}
|
|
146
|
+
try {
|
|
147
|
+
const raw = await client.requestJson(
|
|
148
|
+
`/register/progress/${encodeURIComponent(normalisedAttemptId)}`,
|
|
149
|
+
{ method: "GET" }
|
|
150
|
+
);
|
|
151
|
+
const parsed = client.parseWithSchema(
|
|
152
|
+
raw,
|
|
153
|
+
registrationProgressResponseSchema,
|
|
154
|
+
"registration progress response"
|
|
155
|
+
);
|
|
156
|
+
return parsed.progress;
|
|
157
|
+
} catch (error) {
|
|
158
|
+
if (error instanceof RegistryBrokerError && error.status === 404) {
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function waitForRegistrationCompletion(client, attemptId, options = {}) {
|
|
165
|
+
const normalisedAttemptId = attemptId.trim();
|
|
166
|
+
if (!normalisedAttemptId) {
|
|
167
|
+
throw new Error("attemptId is required");
|
|
168
|
+
}
|
|
169
|
+
const interval = Math.max(
|
|
170
|
+
250,
|
|
171
|
+
options.intervalMs ?? DEFAULT_PROGRESS_INTERVAL_MS
|
|
172
|
+
);
|
|
173
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_PROGRESS_TIMEOUT_MS;
|
|
174
|
+
const throwOnFailure = options.throwOnFailure ?? true;
|
|
175
|
+
const signal = options.signal;
|
|
176
|
+
const startedAt = Date.now();
|
|
177
|
+
while (true) {
|
|
178
|
+
if (signal?.aborted) {
|
|
179
|
+
throw createAbortError();
|
|
180
|
+
}
|
|
181
|
+
const progress = await client.getRegistrationProgress(normalisedAttemptId);
|
|
182
|
+
if (progress) {
|
|
183
|
+
options.onProgress?.(progress);
|
|
184
|
+
if (progress.status === "completed") {
|
|
185
|
+
return progress;
|
|
186
|
+
}
|
|
187
|
+
if (progress.status === "partial" || progress.status === "failed") {
|
|
188
|
+
if (throwOnFailure) {
|
|
189
|
+
throw new RegistryBrokerError(
|
|
190
|
+
"Registration did not complete successfully",
|
|
191
|
+
{
|
|
192
|
+
status: 409,
|
|
193
|
+
statusText: progress.status,
|
|
194
|
+
body: progress
|
|
195
|
+
}
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
return progress;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
if (Date.now() - startedAt >= timeoutMs) {
|
|
202
|
+
throw new Error(
|
|
203
|
+
`Registration progress polling timed out after ${timeoutMs}ms`
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
await client.delay(interval, signal);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
async function validateUaid(client, uaid) {
|
|
210
|
+
const raw = await client.requestJson(
|
|
211
|
+
`/uaids/validate/${encodeURIComponent(uaid)}`,
|
|
212
|
+
{
|
|
213
|
+
method: "GET"
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
return client.parseWithSchema(
|
|
217
|
+
raw,
|
|
218
|
+
uaidValidationResponseSchema,
|
|
219
|
+
"UAID validation response"
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
async function getUaidConnectionStatus(client, uaid) {
|
|
223
|
+
const raw = await client.requestJson(
|
|
224
|
+
`/uaids/connections/${encodeURIComponent(uaid)}/status`,
|
|
225
|
+
{
|
|
226
|
+
method: "GET"
|
|
227
|
+
}
|
|
228
|
+
);
|
|
229
|
+
return client.parseWithSchema(
|
|
230
|
+
raw,
|
|
231
|
+
uaidConnectionStatusSchema,
|
|
232
|
+
"UAID connection status"
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
async function closeUaidConnection(client, uaid) {
|
|
236
|
+
await client.request(`/uaids/connections/${encodeURIComponent(uaid)}`, {
|
|
237
|
+
method: "DELETE"
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
async function dashboardStats(client) {
|
|
241
|
+
const raw = await client.requestJson("/dashboard/stats", {
|
|
242
|
+
method: "GET"
|
|
243
|
+
});
|
|
244
|
+
return client.parseWithSchema(
|
|
245
|
+
raw,
|
|
246
|
+
dashboardStatsResponseSchema,
|
|
247
|
+
"dashboard stats response"
|
|
248
|
+
);
|
|
249
|
+
}
|
|
3
250
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
251
|
+
closeUaidConnection,
|
|
252
|
+
dashboardStats,
|
|
253
|
+
getRegistrationProgress,
|
|
254
|
+
getRegistrationQuote,
|
|
255
|
+
getUaidConnectionStatus,
|
|
256
|
+
registerAgent,
|
|
257
|
+
resolveUaid,
|
|
258
|
+
updateAgent,
|
|
259
|
+
validateUaid,
|
|
260
|
+
waitForRegistrationCompletion
|
|
6
261
|
};
|
|
7
262
|
//# sourceMappingURL=standards-sdk.es153.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standards-sdk.es153.js","sources":["../../src/services/registry-broker/types.ts"],"sourcesContent":["import { z } from 'zod';\nimport type { Signer } from '@hashgraph/sdk';\nimport type { Buffer } from 'buffer';\nimport type {\n AdapterConfigContext,\n AdapterManifest,\n AdapterPackage,\n} from '../../hcs-21/types';\nimport {\n adaptersResponseSchema,\n createSessionResponseSchema,\n encryptionHandshakeResponseSchema,\n detectProtocolResponseSchema,\n dashboardStatsResponseSchema,\n delegationPlanResponseSchema,\n metricsSummaryResponseSchema,\n popularResponseSchema,\n protocolsResponseSchema,\n registerAgentResponseSchema,\n registrationQuoteResponseSchema,\n creditProviderSummarySchema,\n creditProvidersResponseSchema,\n creditBalanceResponseSchema,\n guardBalanceResponseSchema,\n guardBucketBalanceSchema,\n guardEntitlementsSchema,\n guardFeedItemSchema,\n guardFeedResponseSchema,\n guardFeedSummarySchema,\n guardOverviewResponseSchema,\n guardPolicySchema,\n guardPlanIdSchema,\n guardPrincipalSchema,\n guardHistoryArtifactSchema,\n guardReceiptSchema,\n guardReceiptHistoryResponseSchema,\n guardReceiptSyncResponseSchema,\n guardInventoryArtifactSchema,\n guardInventoryResponseSchema,\n guardAbomSummarySchema,\n guardAbomResponseSchema,\n guardTimelineEventSchema,\n guardArtifactTimelineResponseSchema,\n guardReceiptExportSummarySchema,\n guardExportSignatureSchema,\n guardReceiptExportResponseSchema,\n guardAlertPreferencesSchema,\n guardWatchlistItemSchema,\n guardWatchlistLookupResponseSchema,\n guardWatchlistResponseSchema,\n guardPainSignalSchema,\n guardPainSignalListResponseSchema,\n guardPainSignalAggregateSchema,\n guardPainSignalAggregateResponseSchema,\n guardInventoryDiffEntrySchema,\n guardInventoryDiffResponseSchema,\n guardExceptionItemSchema,\n guardExceptionListResponseSchema,\n guardPreflightEvidenceSchema,\n guardPreflightRequestSchema,\n guardPreflightVerdictResponseSchema,\n guardTeamPolicyAuditItemSchema,\n guardTeamPolicyPackSchema,\n guardDeviceSchema,\n guardDeviceListResponseSchema,\n guardRevocationResponseSchema,\n guardSessionResponseSchema,\n guardTrustByHashResponseSchema,\n guardTrustMatchSchema,\n guardTrustResolveResponseSchema,\n creditPurchaseResponseSchema,\n hbarPurchaseIntentResponseSchema,\n x402CreditPurchaseResponseSchema,\n x402MinimumsResponseSchema,\n registriesResponseSchema,\n registrySearchByNamespaceSchema,\n searchFacetsResponseSchema,\n adapterDetailsResponseSchema,\n adapterRegistryAdaptersResponseSchema,\n adapterRegistryCategoriesResponseSchema,\n adapterRegistryCategorySchema,\n adapterRegistryCreateCategoryResponseSchema,\n adapterRegistrySubmitAdapterResponseSchema,\n adapterRegistrySubmitAdapterAcceptedResponseSchema,\n adapterRegistrySubmissionStatusResponseSchema,\n adapterDescriptorSchema,\n adapterChatProfileSchema,\n additionalRegistryCatalogResponseSchema,\n vectorSearchRequestSchema,\n vectorSearchResponseSchema,\n resolveResponseSchema,\n searchResponseSchema,\n sendMessageResponseSchema,\n chatReadinessResponseSchema,\n chatSessionResumeResponseSchema,\n chatSessionEndResponseSchema,\n chatTimelineEntrySchema,\n chatRouteSummarySchema,\n chatPaymentStateSchema,\n chatDeliveryStateSchema,\n chatReadinessStatusSchema,\n chatReplyModeSchema,\n chatRouteTypeSchema,\n chatSessionStateSchema,\n chatErrorCodeSchema,\n chatHistorySnapshotResponseSchema,\n chatHistoryCompactionResponseSchema,\n statsResponseSchema,\n sessionEncryptionStatusResponseSchema,\n uaidConnectionStatusSchema,\n uaidValidationResponseSchema,\n websocketStatsResponseSchema,\n ledgerChallengeResponseSchema,\n ledgerVerifyResponseSchema,\n registerAgentPendingResponseSchema,\n registerAgentPartialResponseSchema,\n registerAgentSuccessResponseSchema,\n registrationProgressAdditionalEntrySchema,\n registrationProgressRecordSchema,\n registrationProgressResponseSchema,\n registerEncryptionKeyResponseSchema,\n searchStatusResponseSchema,\n agentFeedbackResponseSchema,\n agentFeedbackEligibilityResponseSchema,\n agentFeedbackSubmissionResponseSchema,\n agentFeedbackIndexResponseSchema,\n agentFeedbackEntriesIndexResponseSchema,\n moltbookOwnerRegistrationUpdateResponseSchema,\n AIAgentType,\n AIAgentCapability,\n registerStatusResponseSchema,\n verificationChallengeDetailsResponseSchema,\n verificationChallengeResponseSchema,\n verificationOwnershipResponseSchema,\n verificationStatusResponseSchema,\n verificationDnsStatusResponseSchema,\n verificationVerifyResponseSchema,\n verificationVerifySenderResponseSchema,\n skillRegistryConfigResponseSchema,\n skillCatalogChannelSchema,\n skillCatalogSortBySchema,\n skillCatalogVersionSummarySchema,\n skillCatalogItemSchema,\n skillCatalogResponseSchema,\n skillRecommendedVersionResponseSchema,\n skillDeprecationRecordSchema,\n skillDeprecationsResponseSchema,\n skillBadgeMetricSchema,\n skillBadgeStyleSchema,\n skillBadgeResponseSchema,\n skillRegistryTagsResponseSchema,\n skillRegistryCategoriesResponseSchema,\n skillResolverManifestResponseSchema,\n skillRegistryFileDescriptorSchema,\n skillRegistryJobStatusResponseSchema,\n skillSecurityBreakdownResponseSchema,\n skillRegistryListResponseSchema,\n skillRegistryMineResponseSchema,\n skillRegistryMyListResponseSchema,\n skillRegistryOwnershipResponseSchema,\n skillRegistryPublishResponseSchema,\n skillRegistryPublishSummarySchema,\n skillRegistryQuoteResponseSchema,\n skillRegistryVersionsResponseSchema,\n skillRegistryVoteStatusResponseSchema,\n skillVerificationDomainProofChallengeResponseSchema,\n skillVerificationDomainProofVerifyResponseSchema,\n skillVerificationRequestCreateResponseSchema,\n skillVerificationStatusResponseSchema,\n skillTrustTierSchema,\n skillStatusNextStepSchema,\n skillPreviewSuggestedNextStepSchema,\n skillPreviewReportSchema,\n skillPreviewRecordSchema,\n skillPreviewLookupResponseSchema,\n skillStatusPreviewMetadataSchema,\n skillStatusChecksSchema,\n skillStatusVerificationSignalsSchema,\n skillStatusProvenanceSignalsSchema,\n skillStatusResponseSchema,\n skillQuotePreviewRangeSchema,\n skillQuotePreviewResponseSchema,\n skillConversionSignalsResponseSchema,\n skillInstallArtifactDescriptorSchema,\n skillInstallResolverDescriptorSchema,\n skillInstallBadgeDescriptorSchema,\n skillInstallShareDescriptorSchema,\n skillInstallSnippetSetSchema,\n skillInstallResponseSchema,\n skillInstallCopyTelemetryResponseSchema,\n} from './schemas';\n\nexport type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonValue[] | JsonObject;\nexport interface JsonObject {\n [key: string]: JsonValue;\n}\n\nexport interface RegistryBrokerClientOptions {\n baseUrl?: string;\n fetchImplementation?: typeof fetch;\n defaultHeaders?: Record<string, string>;\n apiKey?: string;\n /**\n * Optional account identifier to send as the `x-account-id` header.\n *\n * This is used by some Registry Broker deployments to attribute registrations\n * when no API key / user session is present (for example local docker E2E).\n */\n accountId?: string;\n ledgerApiKey?: string;\n registrationAutoTopUp?: AutoTopUpOptions;\n historyAutoTopUp?: HistoryAutoTopUpOptions;\n encryption?: ClientEncryptionOptions;\n}\n\nexport type ChatHistoryEntry = z.infer<\n typeof createSessionResponseSchema\n>['history'][number];\n\nexport type ChatTimelineEntry = z.infer<typeof chatTimelineEntrySchema>;\n\nexport type CipherEnvelope = NonNullable<ChatHistoryEntry['cipherEnvelope']>;\n\nexport type CipherEnvelopeRecipient = CipherEnvelope['recipients'][number];\n\nexport interface EphemeralKeyPair {\n privateKey: string;\n publicKey: string;\n}\n\nexport interface DeriveSharedSecretOptions {\n privateKey: string;\n peerPublicKey: string;\n}\n\nexport type SharedSecretInput = string | Uint8Array | Buffer;\n\nexport interface EncryptCipherEnvelopeOptions {\n plaintext: string;\n sessionId: string;\n recipients: Array<\n Pick<\n CipherEnvelopeRecipient,\n 'uaid' | 'ledgerAccountId' | 'userId' | 'email'\n >\n >;\n sharedSecret: SharedSecretInput;\n associatedData?: string;\n revision?: number;\n}\n\nexport interface DecryptCipherEnvelopeOptions {\n envelope: CipherEnvelope;\n sharedSecret: SharedSecretInput;\n encoding?: BufferEncoding;\n}\n\nexport type SessionEncryptionStatusResponse = z.infer<\n typeof sessionEncryptionStatusResponseSchema\n>;\n\nexport type SessionEncryptionSummary =\n SessionEncryptionStatusResponse['encryption'];\n\nexport type EncryptionHandshakeResponse = z.infer<\n typeof encryptionHandshakeResponseSchema\n>;\n\nexport type EncryptionHandshakeRecord =\n EncryptionHandshakeResponse['handshake'];\n\nexport interface RegisterEncryptionKeyPayload {\n keyType: 'secp256k1' | 'ed25519' | 'x25519';\n publicKey: string;\n uaid?: string;\n ledgerAccountId?: string;\n ledgerNetwork?: string;\n email?: string;\n}\n\nexport type RegisterEncryptionKeyResponse = z.infer<\n typeof registerEncryptionKeyResponseSchema\n>;\n\nexport interface AgentRegistrationRequestMetadata {\n trustScore?: number;\n verified?: boolean;\n avgLatency?: number;\n uptime?: number;\n provider?: string;\n category?: string;\n adapter?: string;\n openConvAICompatible?: boolean;\n customFields?: Record<string, string | number | boolean>;\n nativeId?: string;\n tunnelUrl?: string;\n publicUrl?: string;\n payments?: JsonValue;\n [key: string]: JsonValue | undefined;\n}\n\nexport interface AgentRegistrationRequest {\n profile: JsonObject;\n endpoint?: string;\n protocol?: string;\n communicationProtocol?: string;\n registry?: string;\n additionalRegistries?: string[];\n metadata?: AgentRegistrationRequestMetadata;\n}\n\nexport interface AutoTopUpOptions {\n accountId: string;\n privateKey: string;\n memo?: string;\n}\n\nexport interface HistoryAutoTopUpOptions extends AutoTopUpOptions {\n hbarAmount?: number;\n}\n\nexport type GuardContractVersion = 1;\n\nexport const GUARD_CANONICAL_PATH_PREFIX = '/api/guard' as const;\nexport const GUARD_COMPAT_PATH_PREFIX = '/guard' as const;\n\nexport type GuardPlanId = z.infer<typeof guardPlanIdSchema>;\n\nexport type GuardPrincipal = z.infer<typeof guardPrincipalSchema>;\n\nexport type GuardEntitlements = z.infer<typeof guardEntitlementsSchema>;\n\nexport type GuardBucketBalance = z.infer<typeof guardBucketBalanceSchema>;\n\nexport type GuardSessionResponse = z.infer<typeof guardSessionResponseSchema>;\n\nexport type GuardBalanceResponse = z.infer<typeof guardBalanceResponseSchema>;\n\nexport type GuardFeedItem = z.infer<typeof guardFeedItemSchema>;\n\nexport type GuardFeedSummary = z.infer<typeof guardFeedSummarySchema>;\n\nexport type GuardFeedResponse = z.infer<typeof guardFeedResponseSchema>;\n\nexport type GuardOverviewResponse = z.infer<typeof guardOverviewResponseSchema>;\n\nexport type GuardPolicy = z.infer<typeof guardPolicySchema>;\n\nexport type GuardTrustMatch = z.infer<typeof guardTrustMatchSchema>;\n\nexport type GuardTrustByHashResponse = z.infer<\n typeof guardTrustByHashResponseSchema\n>;\n\nexport interface GuardTrustResolveQuery {\n ecosystem?: string;\n name?: string;\n version?: string;\n}\n\nexport type GuardTrustResolveResponse = z.infer<\n typeof guardTrustResolveResponseSchema\n>;\n\nexport type GuardRevocationResponse = z.infer<\n typeof guardRevocationResponseSchema\n>;\n\nexport type GuardReceipt = z.infer<typeof guardReceiptSchema>;\n\nexport interface GuardReceiptSyncPayload {\n receipts: GuardReceipt[];\n inventory?: GuardInventoryArtifact[];\n}\n\nexport type GuardReceiptSyncResponse = z.infer<\n typeof guardReceiptSyncResponseSchema\n>;\n\nexport type GuardHistoryArtifact = z.infer<typeof guardHistoryArtifactSchema>;\n\nexport type GuardReceiptHistoryResponse = z.infer<\n typeof guardReceiptHistoryResponseSchema\n>;\n\nexport type GuardInventoryArtifact = z.infer<\n typeof guardInventoryArtifactSchema\n>;\n\nexport type GuardInventoryResponse = z.infer<\n typeof guardInventoryResponseSchema\n>;\n\nexport type GuardInventoryDiffEntry = z.infer<\n typeof guardInventoryDiffEntrySchema\n>;\n\nexport type GuardInventoryDiffResponse = z.infer<\n typeof guardInventoryDiffResponseSchema\n>;\n\nexport type GuardAbomSummary = z.infer<typeof guardAbomSummarySchema>;\n\nexport type GuardAbomResponse = z.infer<typeof guardAbomResponseSchema>;\n\nexport type GuardTimelineEvent = z.infer<typeof guardTimelineEventSchema>;\n\nexport type GuardArtifactTimelineResponse = z.infer<\n typeof guardArtifactTimelineResponseSchema\n>;\n\nexport type GuardReceiptExportSummary = z.infer<\n typeof guardReceiptExportSummarySchema\n>;\n\nexport type GuardExportSignature = z.infer<typeof guardExportSignatureSchema>;\n\nexport type GuardReceiptExportResponse = z.infer<\n typeof guardReceiptExportResponseSchema\n>;\n\nexport type GuardAlertPreferences = z.infer<typeof guardAlertPreferencesSchema>;\n\nexport interface GuardAlertPreferencesUpdate {\n emailEnabled?: boolean;\n digestMode?: GuardAlertPreferences['digestMode'];\n watchlistEnabled?: boolean;\n advisoriesEnabled?: boolean;\n repeatedWarningsEnabled?: boolean;\n teamAlertsEnabled?: boolean;\n}\n\nexport type GuardWatchlistItem = z.infer<typeof guardWatchlistItemSchema>;\n\nexport type GuardWatchlistResponse = z.infer<\n typeof guardWatchlistResponseSchema\n>;\n\nexport type GuardWatchlistLookupResponse = z.infer<\n typeof guardWatchlistLookupResponseSchema\n>;\n\nexport type GuardPainSignal = z.infer<typeof guardPainSignalSchema>;\n\nexport type GuardPainSignalAggregate = z.infer<\n typeof guardPainSignalAggregateSchema\n>;\n\nexport type GuardPainSignalListResponse = z.infer<\n typeof guardPainSignalListResponseSchema\n>;\n\nexport type GuardPainSignalAggregateResponse = z.infer<\n typeof guardPainSignalAggregateResponseSchema\n>;\n\nexport type GuardPreflightEvidence = z.infer<\n typeof guardPreflightEvidenceSchema\n>;\n\nexport type GuardPreflightRequest = z.infer<typeof guardPreflightRequestSchema>;\n\nexport type GuardPreflightVerdictResponse = z.infer<\n typeof guardPreflightVerdictResponseSchema\n>;\n\nexport interface GuardPainSignalIngestItem {\n signalId: string;\n signalName: string;\n artifactId: string;\n artifactName: string;\n artifactType: GuardInventoryArtifact['artifactType'];\n harness: string;\n latestSummary: string;\n occurredAt: string;\n count?: number;\n source?: 'scanner';\n publisher?: string;\n}\n\nexport interface GuardWatchlistUpsert {\n artifactId: string;\n artifactName: string;\n artifactType: GuardInventoryArtifact['artifactType'];\n artifactSlug: string;\n reason: string;\n source: GuardWatchlistItem['source'];\n}\n\nexport type GuardExceptionScope = z.infer<\n typeof guardExceptionItemSchema\n>['scope'];\n\nexport type GuardExceptionSource = z.infer<\n typeof guardExceptionItemSchema\n>['source'];\n\nexport type GuardExceptionItem = z.infer<typeof guardExceptionItemSchema>;\n\nexport type GuardExceptionListResponse = z.infer<\n typeof guardExceptionListResponseSchema\n>;\n\nexport type GuardTeamPolicyAuditItem = z.infer<\n typeof guardTeamPolicyAuditItemSchema\n>;\n\nexport type GuardTeamPolicyPack = z.infer<typeof guardTeamPolicyPackSchema>;\n\nexport interface GuardTeamPolicyPackUpdate {\n name?: string;\n sharedHarnessDefaults?: GuardTeamPolicyPack['sharedHarnessDefaults'];\n allowedPublishers?: string[];\n blockedPublishers?: string[];\n blockedDomains?: string[];\n blockedArtifacts?: string[];\n alertChannel?: GuardTeamPolicyPack['alertChannel'];\n}\n\nexport type GuardDevice = z.infer<typeof guardDeviceSchema>;\n\nexport type GuardDeviceListResponse = z.infer<\n typeof guardDeviceListResponseSchema\n>;\n\nexport interface GuardExceptionUpsert {\n scope: GuardExceptionScope;\n harness?: string | null;\n artifactId?: string | null;\n publisher?: string | null;\n reason: string;\n owner: string;\n source: GuardExceptionSource;\n expiresAt: string;\n}\n\nexport interface RegisterAgentOptions {\n autoTopUp?: AutoTopUpOptions;\n}\n\nexport interface RegistrationProgressWaitOptions {\n intervalMs?: number;\n timeoutMs?: number;\n throwOnFailure?: boolean;\n onProgress?: (progress: RegistrationProgressRecord) => void;\n signal?: AbortSignal;\n}\n\nexport type AgentSearchHit = z.infer<\n typeof searchResponseSchema\n>['hits'][number];\n\nexport type AgentProfile = AgentSearchHit['profile'];\n\nexport type SearchResult = z.infer<typeof searchResponseSchema>;\n\nexport interface SearchParams {\n q?: string;\n page?: number;\n limit?: number;\n registry?: string;\n registries?: string[];\n capabilities?: string[];\n protocols?: string[];\n minTrust?: number;\n adapters?: string[];\n sortBy?: string;\n sortOrder?: 'asc' | 'desc' | string;\n type?: 'ai-agents' | 'mcp-servers' | 'all' | (string & {});\n verified?: boolean;\n online?: boolean;\n metadata?: Record<string, Array<string | number | boolean>>;\n}\n\nexport interface DelegationWorkspaceContext {\n openFiles?: string[];\n modifiedFiles?: string[];\n relatedPaths?: string[];\n errors?: string[];\n commands?: string[];\n languages?: string[];\n}\n\nexport interface DelegationPlanFilter {\n capabilities?: string[];\n type?: 'ai-agents' | 'mcp-servers';\n registry?: string;\n registries?: string[];\n protocols?: string[];\n adapters?: string[];\n verifiedOnly?: boolean;\n onlineOnly?: boolean;\n minTrust?: number;\n minTrustSignals?: Record<string, number>;\n metadata?: Record<string, Array<string | number | boolean>>;\n metadataRanges?: Record<string, { min?: number; max?: number }>;\n}\n\nexport interface DelegationPlanRequest {\n task: string;\n context?: string;\n workspace?: DelegationWorkspaceContext;\n limit?: number;\n filter?: DelegationPlanFilter;\n}\n\nexport type DelegationPlanCandidate = z.infer<\n typeof delegationPlanResponseSchema\n>['opportunities'][number]['candidates'][number];\n\nexport type DelegationOpportunity = z.infer<\n typeof delegationPlanResponseSchema\n>['opportunities'][number];\n\nexport type DelegationPlanResponse = z.infer<\n typeof delegationPlanResponseSchema\n>;\n\nexport type RegistryStatsResponse = z.infer<typeof statsResponseSchema>;\n\nexport type RegistriesResponse = z.infer<typeof registriesResponseSchema>;\n\nexport type PopularSearchesResponse = z.infer<typeof popularResponseSchema>;\n\nexport type ResolvedAgentResponse = z.infer<typeof resolveResponseSchema>;\n\nexport type CreateSessionResponse = z.infer<typeof createSessionResponseSchema>;\n\nexport type ChatSessionResumeResponse = z.infer<\n typeof chatSessionResumeResponseSchema\n>;\n\nexport type SendMessageResponse = z.infer<typeof sendMessageResponseSchema>;\nexport type ChatReadinessResponse = z.infer<typeof chatReadinessResponseSchema>;\nexport type ChatSessionEndResponse = z.infer<\n typeof chatSessionEndResponseSchema\n>;\nexport type ChatRouteSummary = z.infer<typeof chatRouteSummarySchema>;\nexport type ChatPaymentState = z.infer<typeof chatPaymentStateSchema>;\nexport type ChatDeliveryState = z.infer<typeof chatDeliveryStateSchema>;\nexport type ChatReadinessStatus = z.infer<typeof chatReadinessStatusSchema>;\nexport type ChatReplyMode = z.infer<typeof chatReplyModeSchema>;\nexport type ChatRouteType = z.infer<typeof chatRouteTypeSchema>;\nexport type ChatSessionState = z.infer<typeof chatSessionStateSchema>;\nexport type ChatErrorCode = z.infer<typeof chatErrorCodeSchema>;\nexport type ChatRetryResponse = SendMessageResponse;\nexport type SkillSecurityBreakdownResponse = z.infer<\n typeof skillSecurityBreakdownResponseSchema\n>;\nexport type ChatHistorySnapshotResponse = z.infer<\n typeof chatHistorySnapshotResponseSchema\n>;\nexport type ChatHistoryCompactionResponse = z.infer<\n typeof chatHistoryCompactionResponseSchema\n>;\n\nexport type AgentFeedbackResponse = z.infer<typeof agentFeedbackResponseSchema>;\nexport type AgentFeedbackEligibilityResponse = z.infer<\n typeof agentFeedbackEligibilityResponseSchema\n>;\nexport type AgentFeedbackSubmissionResponse = z.infer<\n typeof agentFeedbackSubmissionResponseSchema\n>;\nexport type AgentFeedbackIndexResponse = z.infer<\n typeof agentFeedbackIndexResponseSchema\n>;\n\nexport type VerificationStatusResponse = z.infer<\n typeof verificationStatusResponseSchema\n>;\nexport type VerificationChallengeResponse = z.infer<\n typeof verificationChallengeResponseSchema\n>;\nexport type VerificationChallengeDetailsResponse = z.infer<\n typeof verificationChallengeDetailsResponseSchema\n>;\nexport type VerificationVerifyResponse = z.infer<\n typeof verificationVerifyResponseSchema\n>;\nexport type VerificationOwnershipResponse = z.infer<\n typeof verificationOwnershipResponseSchema\n>;\nexport type VerificationVerifySenderResponse = z.infer<\n typeof verificationVerifySenderResponseSchema\n>;\nexport type VerificationDnsStatusResponse = z.infer<\n typeof verificationDnsStatusResponseSchema\n>;\n\nexport type RegisterStatusResponse = z.infer<\n typeof registerStatusResponseSchema\n>;\n\nexport type MoltbookOwnerRegistrationUpdateResponse = z.infer<\n typeof moltbookOwnerRegistrationUpdateResponseSchema\n>;\n\nexport type SkillRegistryFileDescriptor = z.infer<\n typeof skillRegistryFileDescriptorSchema\n>;\nexport type SkillRegistryPublishSummary = z.infer<\n typeof skillRegistryPublishSummarySchema\n>;\nexport type SkillRegistryListResponse = z.infer<\n typeof skillRegistryListResponseSchema\n>;\nexport type SkillRegistryMineResponse = z.infer<\n typeof skillRegistryMineResponseSchema\n>;\nexport type SkillRegistryMyListResponse = z.infer<\n typeof skillRegistryMyListResponseSchema\n>;\nexport type SkillRegistryQuoteResponse = z.infer<\n typeof skillRegistryQuoteResponseSchema\n>;\nexport type SkillRegistryPublishResponse = z.infer<\n typeof skillRegistryPublishResponseSchema\n>;\nexport type SkillRegistryJobStatusResponse = z.infer<\n typeof skillRegistryJobStatusResponseSchema\n>;\nexport type SkillRegistryConfigResponse = z.infer<\n typeof skillRegistryConfigResponseSchema\n>;\nexport type SkillCatalogChannel = z.infer<typeof skillCatalogChannelSchema>;\nexport type SkillCatalogSortBy = z.infer<typeof skillCatalogSortBySchema>;\nexport type SkillCatalogVersionSummary = z.infer<\n typeof skillCatalogVersionSummarySchema\n>;\nexport type SkillCatalogItem = z.infer<typeof skillCatalogItemSchema>;\nexport type SkillCatalogResponse = z.infer<typeof skillCatalogResponseSchema>;\nexport type SkillRecommendedVersionResponse = z.infer<\n typeof skillRecommendedVersionResponseSchema\n>;\nexport type SkillDeprecationRecord = z.infer<\n typeof skillDeprecationRecordSchema\n>;\nexport type SkillDeprecationsResponse = z.infer<\n typeof skillDeprecationsResponseSchema\n>;\nexport type SkillBadgeMetric = z.infer<typeof skillBadgeMetricSchema>;\nexport type SkillBadgeStyle = z.infer<typeof skillBadgeStyleSchema>;\nexport type SkillBadgeResponse = z.infer<typeof skillBadgeResponseSchema>;\nexport type SkillRegistryTagsResponse = z.infer<\n typeof skillRegistryTagsResponseSchema\n>;\nexport type SkillRegistryCategoriesResponse = z.infer<\n typeof skillRegistryCategoriesResponseSchema\n>;\nexport type SkillResolverManifestResponse = z.infer<\n typeof skillResolverManifestResponseSchema\n>;\nexport type SkillRegistryOwnershipResponse = z.infer<\n typeof skillRegistryOwnershipResponseSchema\n>;\nexport type SkillRegistryVersionsResponse = z.infer<\n typeof skillRegistryVersionsResponseSchema\n>;\nexport type SkillRegistryVoteStatusResponse = z.infer<\n typeof skillRegistryVoteStatusResponseSchema\n>;\nexport type SkillTrustTier = z.infer<typeof skillTrustTierSchema>;\nexport type SkillStatusNextStep = z.infer<typeof skillStatusNextStepSchema>;\nexport type SkillPreviewSuggestedNextStep = z.infer<\n typeof skillPreviewSuggestedNextStepSchema\n>;\nexport type SkillPreviewReport = z.infer<typeof skillPreviewReportSchema>;\nexport type SkillPreviewRecord = z.infer<typeof skillPreviewRecordSchema>;\nexport type SkillPreviewLookupResponse = z.infer<\n typeof skillPreviewLookupResponseSchema\n>;\nexport type SkillStatusPreviewMetadata = z.infer<\n typeof skillStatusPreviewMetadataSchema\n>;\nexport type SkillStatusChecks = z.infer<typeof skillStatusChecksSchema>;\nexport type SkillStatusVerificationSignals = z.infer<\n typeof skillStatusVerificationSignalsSchema\n>;\nexport type SkillStatusProvenanceSignals = z.infer<\n typeof skillStatusProvenanceSignalsSchema\n>;\nexport type SkillStatusResponse = z.infer<typeof skillStatusResponseSchema>;\nexport type SkillQuotePreviewRange = z.infer<\n typeof skillQuotePreviewRangeSchema\n>;\nexport type SkillQuotePreviewResponse = z.infer<\n typeof skillQuotePreviewResponseSchema\n>;\nexport type SkillConversionSignalsResponse = z.infer<\n typeof skillConversionSignalsResponseSchema\n>;\nexport type SkillInstallArtifactDescriptor = z.infer<\n typeof skillInstallArtifactDescriptorSchema\n>;\nexport type SkillInstallResolverDescriptor = z.infer<\n typeof skillInstallResolverDescriptorSchema\n>;\nexport type SkillInstallBadgeDescriptor = z.infer<\n typeof skillInstallBadgeDescriptorSchema\n>;\nexport type SkillInstallShareDescriptor = z.infer<\n typeof skillInstallShareDescriptorSchema\n>;\nexport type SkillInstallSnippetSet = z.infer<\n typeof skillInstallSnippetSetSchema\n>;\nexport type SkillInstallResponse = z.infer<typeof skillInstallResponseSchema>;\nexport type SkillInstallCopyTelemetryResponse = z.infer<\n typeof skillInstallCopyTelemetryResponseSchema\n>;\n\nexport type SkillVerificationRequestCreateResponse = z.infer<\n typeof skillVerificationRequestCreateResponseSchema\n>;\nexport type SkillVerificationStatusResponse = z.infer<\n typeof skillVerificationStatusResponseSchema\n>;\nexport type SkillVerificationDomainProofChallengeResponse = z.infer<\n typeof skillVerificationDomainProofChallengeResponseSchema\n>;\nexport type SkillVerificationDomainProofVerifyResponse = z.infer<\n typeof skillVerificationDomainProofVerifyResponseSchema\n>;\nexport type SkillVerificationRequest =\n SkillVerificationRequestCreateResponse['request'];\nexport type SkillVerificationTier = SkillVerificationRequest['tier'];\n\nexport type SkillRegistryFileRole =\n | 'skill-md'\n | 'skill-json'\n | 'skill-icon'\n | 'file';\n\nexport interface SkillRegistryFileInput {\n name: string;\n base64: string;\n mimeType?: string | null;\n role?: SkillRegistryFileRole | null;\n}\n\nexport interface SkillRegistryQuoteRequest {\n files: SkillRegistryFileInput[];\n directoryTopicId?: string;\n accountId?: string;\n}\n\nexport interface SkillListOptions {\n name?: string;\n version?: string;\n limit?: number;\n cursor?: string;\n includeFiles?: boolean;\n accountId?: string;\n q?: string;\n tag?: string;\n category?: string;\n featured?: boolean;\n verified?: boolean;\n view?: 'latest' | 'all';\n}\n\nexport interface SkillCatalogQueryOptions {\n q?: string;\n category?: string;\n tags?: string[];\n featured?: boolean;\n verified?: boolean;\n channel?: SkillCatalogChannel;\n sortBy?: SkillCatalogSortBy;\n limit?: number;\n cursor?: string;\n}\n\nexport interface SkillRegistryPublishRequest {\n files: SkillRegistryFileInput[];\n directoryTopicId?: string;\n accountId?: string;\n quoteId?: string;\n publisher?: string | null;\n}\n\nexport interface SkillRegistryVoteRequest {\n name: string;\n upvoted: boolean;\n}\n\nexport interface SkillSecurityBreakdownRequest {\n jobId: string;\n}\n\nexport interface SkillStatusRequest {\n name: string;\n version?: string;\n}\n\nexport interface SkillPreviewLookupRequest {\n name: string;\n version?: string;\n}\n\nexport interface SkillPreviewByRepoRequest {\n repo: string;\n skillDir: string;\n ref?: string;\n}\n\nexport interface SkillQuotePreviewRequest {\n fileCount: number;\n totalBytes: number;\n name?: string;\n version?: string;\n repoUrl?: string;\n skillDir?: string;\n}\n\nexport interface UploadSkillPreviewFromGithubOidcRequest {\n token: string;\n report: SkillPreviewReport;\n}\n\nexport interface SkillInstallCopyTelemetryRequest {\n source?: string;\n installType?:\n | 'cli'\n | 'skillmd'\n | 'manifest'\n | 'claude'\n | 'cursor'\n | 'codex'\n | 'openclaw';\n}\n\nexport interface SkillVerificationRequestCreateRequest {\n name: string;\n version?: string;\n tier: SkillVerificationTier;\n}\n\nexport interface SkillVerificationDomainProofChallengeRequest {\n name: string;\n version?: string;\n domain?: string;\n}\n\nexport interface SkillVerificationDomainProofVerifyRequest {\n name: string;\n version?: string;\n domain?: string;\n challengeToken: string;\n}\n\nexport interface SkillRecommendedVersionSetRequest {\n name: string;\n version: string;\n}\n\nexport interface SkillDeprecationSetRequest {\n name: string;\n version?: string;\n reason: string;\n replacementRef?: string;\n}\n\nexport interface SkillBadgeQuery {\n name: string;\n metric?: SkillBadgeMetric;\n label?: string;\n style?: SkillBadgeStyle;\n}\n\nexport interface MoltbookOwnerRegistrationUpdateRequest {\n registered?: boolean;\n name?: string;\n description?: string;\n endpoint?: string;\n metadata?: JsonObject;\n}\n\nexport interface VerificationDnsVerifyRequest {\n uaid: string;\n persist?: boolean;\n}\n\nexport interface VerificationDnsStatusQuery {\n refresh?: boolean;\n persist?: boolean;\n}\n\nexport type AgentFeedbackEntriesIndexResponse = z.infer<\n typeof agentFeedbackEntriesIndexResponseSchema\n>;\n\nexport interface AgentFeedbackQuery {\n includeRevoked?: boolean;\n}\n\nexport interface AgentFeedbackEligibilityRequest {\n sessionId: string;\n}\n\nexport interface AgentFeedbackSubmissionRequest {\n sessionId: string;\n score: number;\n tag1?: string;\n tag2?: string;\n fileUri?: string;\n fileHash?: string;\n}\n\nexport type RegisterAgentSuccessResponse = z.infer<\n typeof registerAgentSuccessResponseSchema\n>;\nexport type RegisterAgentPendingResponse = z.infer<\n typeof registerAgentPendingResponseSchema\n>;\nexport type RegisterAgentPartialResponse = z.infer<\n typeof registerAgentPartialResponseSchema\n>;\nexport type RegisterAgentResponse = z.infer<typeof registerAgentResponseSchema>;\n\nexport type RegistrationProgressAdditionalEntry = z.infer<\n typeof registrationProgressAdditionalEntrySchema\n>;\nexport type RegistrationProgressRecord = z.infer<\n typeof registrationProgressRecordSchema\n>;\nexport type RegistrationProgressResponse = z.infer<\n typeof registrationProgressResponseSchema\n>;\nexport type RegisterAgentQuoteResponse = z.infer<\n typeof registrationQuoteResponseSchema\n>;\nexport type CreditProviderSummary = z.infer<typeof creditProviderSummarySchema>;\nexport type CreditProvidersResponse = z.infer<\n typeof creditProvidersResponseSchema\n>;\nexport type CreditBalanceResponse = z.infer<typeof creditBalanceResponseSchema>;\nexport interface HbarPurchaseIntentRequest {\n accountId?: string;\n credits?: number;\n hbarAmount?: number;\n memo?: string;\n}\nexport type HbarPurchaseIntentResponse = z.infer<\n typeof hbarPurchaseIntentResponseSchema\n>;\nexport type CreditPurchaseResponse = z.infer<\n typeof creditPurchaseResponseSchema\n>;\nexport type X402CreditPurchaseResponse = z.infer<\n typeof x402CreditPurchaseResponseSchema\n>;\nexport type X402MinimumsResponse = z.infer<typeof x402MinimumsResponseSchema>;\nexport type AdditionalRegistryCatalogResponse = z.infer<\n typeof additionalRegistryCatalogResponseSchema\n>;\nexport type AdditionalRegistryDescriptor =\n AdditionalRegistryCatalogResponse['registries'][number];\nexport type AdditionalRegistryNetworkDescriptor =\n AdditionalRegistryDescriptor['networks'][number];\n\nexport type AdapterDetailsResponse = z.infer<\n typeof adapterDetailsResponseSchema\n>;\n\nexport interface LedgerChallengeRequest {\n accountId: string;\n network: string;\n}\n\nexport type LedgerChallengeResponse = z.infer<\n typeof ledgerChallengeResponseSchema\n>;\n\nexport interface LedgerAuthenticationSignerResult {\n signature: string;\n signatureKind?: 'raw' | 'map' | 'evm';\n publicKey?: string;\n}\n\nexport interface LedgerAuthenticationOptions extends LedgerChallengeRequest {\n signer?: Signer;\n sign?: (\n message: string,\n ) =>\n | LedgerAuthenticationSignerResult\n | Promise<LedgerAuthenticationSignerResult>;\n expiresInMinutes?: number;\n}\n\nexport interface LedgerVerifyRequest extends LedgerChallengeRequest {\n challengeId: string;\n signature: string;\n signatureKind?: 'raw' | 'map' | 'evm';\n publicKey?: string;\n expiresInMinutes?: number;\n}\n\nexport type LedgerVerifyResponse = z.infer<typeof ledgerVerifyResponseSchema>;\n\nexport interface LedgerAuthenticationLogger {\n info?: (message: string) => void;\n warn?: (message: string) => void;\n}\n\nexport interface LedgerCredentialAuthOptions {\n accountId: string;\n network: string;\n signer?: Signer;\n sign?: (\n message: string,\n ) =>\n | LedgerAuthenticationSignerResult\n | Promise<LedgerAuthenticationSignerResult>;\n hederaPrivateKey?: string;\n evmPrivateKey?: string;\n expiresInMinutes?: number;\n setAccountHeader?: boolean;\n label?: string;\n logger?: LedgerAuthenticationLogger;\n}\n\nexport type ProtocolsResponse = z.infer<typeof protocolsResponseSchema>;\n\nexport type DetectProtocolResponse = z.infer<\n typeof detectProtocolResponseSchema\n>;\n\nexport type ProtocolDetectionMessage = JsonObject;\n\nexport type RegistrySearchByNamespaceResponse = z.infer<\n typeof registrySearchByNamespaceSchema\n>;\n\nexport type WebsocketStatsResponse = z.infer<\n typeof websocketStatsResponseSchema\n>;\n\nexport type MetricsSummaryResponse = z.infer<\n typeof metricsSummaryResponseSchema\n>;\n\nexport type UaidValidationResponse = z.infer<\n typeof uaidValidationResponseSchema\n>;\n\nexport type UaidConnectionStatus = z.infer<typeof uaidConnectionStatusSchema>;\n\nexport type DashboardStatsResponse = z.infer<\n typeof dashboardStatsResponseSchema\n>;\n\nexport type VectorSearchFilter = z.infer<\n typeof vectorSearchRequestSchema\n>['filter'];\n\nexport type VectorSearchRequest = z.infer<typeof vectorSearchRequestSchema>;\n\nexport type VectorSearchResponse = z.infer<typeof vectorSearchResponseSchema>;\nexport type SearchStatusResponse = z.infer<typeof searchStatusResponseSchema>;\n\ntype CreateSessionBasePayload = {\n auth?: AgentAuthConfig;\n historyTtlSeconds?: number;\n encryptionRequested?: boolean;\n senderUaid?: string;\n visibility?: 'private' | 'public';\n idempotencyKey?: string;\n};\n\nexport type CreateSessionRequestPayload =\n | (CreateSessionBasePayload & { uaid: string })\n | (CreateSessionBasePayload & { agentUrl: string });\n\nexport type ChatReadinessRequestPayload =\n | { uaid: string; agentUrl?: never; forceRefresh?: boolean }\n | { agentUrl: string; uaid?: never; forceRefresh?: boolean };\n\nexport interface ChatRetryRequestPayload extends SendMessageBasePayload {\n sessionId: string;\n uaid?: string;\n agentUrl?: string;\n}\n\nexport interface CompactHistoryRequestPayload {\n sessionId: string;\n preserveEntries?: number;\n}\n\nexport interface SendMessageEncryptionOptions\n extends Omit<EncryptCipherEnvelopeOptions, 'sessionId'> {\n sessionId?: string;\n}\n\nexport interface SendMessageBasePayload {\n message: string;\n streaming?: boolean;\n auth?: AgentAuthConfig;\n cipherEnvelope?: CipherEnvelope;\n encryption?: SendMessageEncryptionOptions;\n idempotencyKey?: string;\n senderUaid?: string;\n transport?: 'xmtp' | 'moltbook' | 'http' | 'a2a' | 'acp';\n}\n\nexport interface StartEncryptedChatSessionOptions {\n uaid: string;\n senderUaid?: string;\n historyTtlSeconds?: number;\n handshakeTimeoutMs?: number;\n pollIntervalMs?: number;\n onSessionCreated?: (sessionId: string) => void;\n auth?: AgentAuthConfig;\n}\n\nexport interface AcceptEncryptedChatSessionOptions {\n sessionId: string;\n responderUaid?: string;\n handshakeTimeoutMs?: number;\n pollIntervalMs?: number;\n}\n\nexport interface EncryptedChatSendOptions {\n plaintext: string;\n message?: string;\n recipients?: Array<\n Pick<\n CipherEnvelopeRecipient,\n 'uaid' | 'ledgerAccountId' | 'userId' | 'email'\n >\n >;\n streaming?: boolean;\n auth?: AgentAuthConfig;\n}\n\nexport type ConversationMode = 'encrypted' | 'plaintext';\n\nexport interface DecryptedHistoryEntry {\n entry: ChatHistoryEntry;\n plaintext: string | null;\n}\n\nexport interface ChatConversationHandle {\n sessionId: string;\n mode: ConversationMode;\n summary?: SessionEncryptionSummary | null;\n send: (options: EncryptedChatSendOptions) => Promise<SendMessageResponse>;\n decryptHistoryEntry: (entry: ChatHistoryEntry) => string | null;\n fetchHistory: (\n options?: ChatHistoryFetchOptions,\n ) => Promise<DecryptedHistoryEntry[]>;\n}\n\nexport interface EncryptedChatSessionHandle extends ChatConversationHandle {\n summary: SessionEncryptionSummary;\n mode: 'encrypted';\n}\n\nexport type RecipientIdentity = Pick<\n CipherEnvelopeRecipient,\n 'uaid' | 'ledgerAccountId' | 'userId' | 'email'\n>;\n\nexport interface ChatHistoryFetchOptions {\n decrypt?: boolean;\n identity?: RecipientIdentity;\n sharedSecret?: SharedSecretInput;\n}\n\nexport type ChatHistorySnapshotWithDecryptedEntries =\n ChatHistorySnapshotResponse & {\n decryptedHistory?: DecryptedHistoryEntry[];\n };\n\nexport interface ConversationEncryptionOptions {\n preference?: 'preferred' | 'required' | 'disabled';\n handshakeTimeoutMs?: number;\n pollIntervalMs?: number;\n}\n\nexport interface StartConversationOptions {\n uaid: string;\n senderUaid?: string;\n historyTtlSeconds?: number;\n auth?: AgentAuthConfig;\n encryption?: ConversationEncryptionOptions;\n onSessionCreated?: (sessionId: string) => void;\n}\n\nexport interface AcceptConversationOptions {\n sessionId: string;\n responderUaid?: string;\n encryption?: ConversationEncryptionOptions;\n}\n\nexport interface StartChatBaseOptions {\n auth?: AgentAuthConfig;\n historyTtlSeconds?: number;\n encryption?: ConversationEncryptionOptions;\n senderUaid?: string;\n onSessionCreated?: (sessionId: string) => void;\n}\n\nexport type StartChatOptions =\n | (StartChatBaseOptions & { uaid: string; agentUrl?: never })\n | (StartChatBaseOptions & { agentUrl: string; uaid?: never });\n\nexport interface AutoRegisterEncryptionKeyOptions {\n enabled?: boolean;\n keyType?: 'secp256k1';\n publicKey?: string;\n privateKey?: string;\n envVar?: string;\n envPath?: string;\n generateIfMissing?: boolean;\n overwriteEnv?: boolean;\n uaid?: string;\n ledgerAccountId?: string;\n ledgerNetwork?: string;\n email?: string;\n label?: string;\n}\n\nexport interface ClientEncryptionOptions {\n autoRegister?: AutoRegisterEncryptionKeyOptions;\n autoDecryptHistory?: boolean;\n}\n\nexport interface EnsureAgentKeyOptions\n extends Omit<AutoRegisterEncryptionKeyOptions, 'enabled' | 'uaid'> {\n uaid: string;\n}\n\nexport interface InitializeAgentClientOptions\n extends RegistryBrokerClientOptions {\n uaid: string;\n ensureEncryptionKey?: boolean | EnsureAgentKeyOptions;\n}\n\nexport type SendMessageRequestPayload =\n | (SendMessageBasePayload & { uaid: string })\n | (SendMessageBasePayload & { sessionId: string })\n | (SendMessageBasePayload & { agentUrl: string; sessionId?: string });\n\nexport interface EncryptionHandshakeSubmissionPayload {\n role: 'requester' | 'responder';\n keyType: string;\n ephemeralPublicKey: string;\n longTermPublicKey?: string;\n signature?: string;\n uaid?: string;\n userId?: string;\n ledgerAccountId?: string;\n metadata?: Record<string, JsonValue>;\n}\nexport type AgentAuthType = 'bearer' | 'basic' | 'header' | 'apiKey';\n\nexport interface AgentAuthConfig {\n type?: AgentAuthType;\n token?: string;\n username?: string;\n password?: string;\n headerName?: string;\n headerValue?: string;\n headers?: Record<string, string>;\n}\n\nexport type AdaptersResponse = z.infer<typeof adaptersResponseSchema>;\n\nexport type AdapterRegistryCategory = z.infer<\n typeof adapterRegistryCategorySchema\n>;\n\nexport type AdapterRegistryCategoriesResponse = z.infer<\n typeof adapterRegistryCategoriesResponseSchema\n>;\n\nexport type AdapterRegistryAdaptersResponse = z.infer<\n typeof adapterRegistryAdaptersResponseSchema\n>;\n\nexport type AdapterRegistryCreateCategoryResponse = z.infer<\n typeof adapterRegistryCreateCategoryResponseSchema\n>;\n\nexport type AdapterRegistrySubmitAdapterResponse = z.infer<\n typeof adapterRegistrySubmitAdapterResponseSchema\n>;\n\nexport type AdapterRegistrySubmitAdapterAcceptedResponse = z.infer<\n typeof adapterRegistrySubmitAdapterAcceptedResponseSchema\n>;\n\nexport type AdapterRegistrySubmissionStatusResponse = z.infer<\n typeof adapterRegistrySubmissionStatusResponseSchema\n>;\n\nexport interface CreateAdapterRegistryCategoryRequest {\n name: string;\n description?: string;\n type?: 'adapter-type' | 'custom';\n slug?: string;\n metadata?: {\n version?: string;\n name?: string;\n description?: string;\n operator?: {\n account?: string;\n name?: string;\n contact?: string;\n };\n entityTypes?: string[];\n categories?: string[];\n tags?: string[];\n links?: Record<string, string>;\n };\n}\n\nexport interface SubmitAdapterRegistryAdapterRequest {\n adapterId: string;\n adapterName: string;\n entity: string;\n package: AdapterPackage;\n config: AdapterConfigContext;\n stateModel?: string;\n signature?: string;\n manifest: AdapterManifest;\n manifestPointer?: string;\n manifestSequence?: number;\n keywords?: string[];\n categorySlug?: string;\n newCategory?: CreateAdapterRegistryCategoryRequest;\n}\n\nexport type SearchFacetsResponse = z.infer<typeof searchFacetsResponseSchema>;\n"],"names":[],"mappings":"AAoUO,MAAM,8BAA8B;AACpC,MAAM,2BAA2B;"}
|
|
1
|
+
{"version":3,"file":"standards-sdk.es153.js","sources":["../../src/services/registry-broker/client/agents.ts"],"sourcesContent":["import type {\n AgentRegistrationRequest,\n DashboardStatsResponse,\n JsonValue,\n RegisterAgentOptions,\n RegisterAgentQuoteResponse,\n RegisterAgentResponse,\n RegistrationProgressRecord,\n RegistrationProgressWaitOptions,\n ResolvedAgentResponse,\n UaidConnectionStatus,\n UaidValidationResponse,\n} from '../types';\nimport {\n dashboardStatsResponseSchema,\n registerAgentResponseSchema,\n registrationProgressResponseSchema,\n registrationQuoteResponseSchema,\n resolveResponseSchema,\n uaidConnectionStatusSchema,\n uaidValidationResponseSchema,\n} from '../schemas';\nimport type { RegistryBrokerClient } from './base-client';\nimport { purchaseCreditsWithHbar } from './credits';\nimport {\n createAbortError,\n DEFAULT_PROGRESS_INTERVAL_MS,\n DEFAULT_PROGRESS_TIMEOUT_MS,\n MINIMUM_REGISTRATION_AUTO_TOP_UP_CREDITS,\n serialiseAgentRegistrationRequest,\n} from './utils';\nimport { RegistryBrokerError } from './errors';\n\nasync function performRegisterAgent(\n client: RegistryBrokerClient,\n payload: AgentRegistrationRequest,\n): Promise<RegisterAgentResponse> {\n const raw = await client.requestJson<JsonValue>('/register', {\n method: 'POST',\n body: serialiseAgentRegistrationRequest(payload),\n headers: { 'content-type': 'application/json' },\n });\n return client.parseWithSchema(\n raw,\n registerAgentResponseSchema,\n 'register agent response',\n );\n}\n\nfunction calculateHbarAmount(\n creditsToPurchase: number,\n creditsPerHbar: number,\n): number {\n if (creditsPerHbar <= 0) {\n throw new Error('creditsPerHbar must be positive');\n }\n if (creditsToPurchase <= 0) {\n throw new Error('creditsToPurchase must be positive');\n }\n const rawHbar = creditsToPurchase / creditsPerHbar;\n const tinybars = Math.ceil(rawHbar * 1e8);\n return tinybars / 1e8;\n}\n\nfunction resolveCreditsToPurchase(shortfallCredits: number): number {\n if (!Number.isFinite(shortfallCredits) || shortfallCredits <= 0) {\n return 0;\n }\n return Math.max(\n Math.ceil(shortfallCredits),\n MINIMUM_REGISTRATION_AUTO_TOP_UP_CREDITS,\n );\n}\n\nasync function ensureCreditsForRegistration(\n client: RegistryBrokerClient,\n payload: AgentRegistrationRequest,\n autoTopUp: RegisterAgentOptions['autoTopUp'],\n): Promise<void> {\n const details = autoTopUp ?? null;\n if (!details) {\n return;\n }\n\n if (!details.accountId || !details.accountId.trim()) {\n throw new Error('autoTopUp.accountId is required');\n }\n\n if (!details.privateKey || !details.privateKey.trim()) {\n throw new Error('autoTopUp.privateKey is required');\n }\n\n for (let attempt = 0; attempt < 3; attempt += 1) {\n const quote = await getRegistrationQuote(client, payload);\n const shortfall = quote.shortfallCredits ?? 0;\n if (shortfall <= 0) {\n return;\n }\n const creditsToPurchase = resolveCreditsToPurchase(shortfall);\n if (creditsToPurchase <= 0) {\n return;\n }\n\n const creditsPerHbar = quote.creditsPerHbar ?? null;\n if (!creditsPerHbar || creditsPerHbar <= 0) {\n throw new Error('Unable to determine credits per HBAR for auto top-up');\n }\n\n const hbarAmount = calculateHbarAmount(creditsToPurchase, creditsPerHbar);\n\n await purchaseCreditsWithHbar(client, {\n accountId: details.accountId.trim(),\n privateKey: details.privateKey.trim(),\n hbarAmount,\n memo: details.memo ?? 'Registry Broker auto top-up',\n metadata: {\n shortfallCredits: shortfall,\n requiredCredits: quote.requiredCredits,\n purchasedCredits: creditsToPurchase,\n },\n });\n }\n\n const finalQuote = await getRegistrationQuote(client, payload);\n if ((finalQuote.shortfallCredits ?? 0) > 0) {\n throw new Error('Unable to purchase sufficient credits for registration');\n }\n}\n\nexport async function resolveUaid(\n client: RegistryBrokerClient,\n uaid: string,\n): Promise<ResolvedAgentResponse> {\n const raw = await client.requestJson<JsonValue>(\n `/resolve/${encodeURIComponent(uaid)}`,\n {\n method: 'GET',\n },\n );\n return client.parseWithSchema(\n raw,\n resolveResponseSchema,\n 'resolve UAID response',\n );\n}\n\nexport async function registerAgent(\n client: RegistryBrokerClient,\n payload: AgentRegistrationRequest,\n options?: RegisterAgentOptions,\n): Promise<RegisterAgentResponse> {\n const autoTopUp = options?.autoTopUp ?? client.registrationAutoTopUp;\n\n if (!autoTopUp) {\n return performRegisterAgent(client, payload);\n }\n\n await ensureCreditsForRegistration(client, payload, autoTopUp);\n\n let retried = false;\n while (true) {\n try {\n return await performRegisterAgent(client, payload);\n } catch (error) {\n const shortfall = client.extractInsufficientCreditsDetails(error);\n if (shortfall && !retried) {\n await ensureCreditsForRegistration(client, payload, autoTopUp);\n retried = true;\n continue;\n }\n throw error;\n }\n }\n}\n\nexport async function getRegistrationQuote(\n client: RegistryBrokerClient,\n payload: AgentRegistrationRequest,\n): Promise<RegisterAgentQuoteResponse> {\n const raw = await client.requestJson<JsonValue>('/register/quote', {\n method: 'POST',\n body: serialiseAgentRegistrationRequest(payload),\n headers: { 'content-type': 'application/json' },\n });\n\n return client.parseWithSchema(\n raw,\n registrationQuoteResponseSchema,\n 'registration quote response',\n );\n}\n\nexport async function updateAgent(\n client: RegistryBrokerClient,\n uaid: string,\n payload: AgentRegistrationRequest,\n): Promise<RegisterAgentResponse> {\n const raw = await client.requestJson<JsonValue>(\n `/register/${encodeURIComponent(uaid)}`,\n {\n method: 'PUT',\n body: serialiseAgentRegistrationRequest(payload),\n headers: { 'content-type': 'application/json' },\n },\n );\n\n return client.parseWithSchema(\n raw,\n registerAgentResponseSchema,\n 'update agent response',\n );\n}\n\nexport async function getRegistrationProgress(\n client: RegistryBrokerClient,\n attemptId: string,\n): Promise<RegistrationProgressRecord | null> {\n const normalisedAttemptId = attemptId.trim();\n if (!normalisedAttemptId) {\n throw new Error('attemptId is required');\n }\n\n try {\n const raw = await client.requestJson<JsonValue>(\n `/register/progress/${encodeURIComponent(normalisedAttemptId)}`,\n { method: 'GET' },\n );\n\n const parsed = client.parseWithSchema(\n raw,\n registrationProgressResponseSchema,\n 'registration progress response',\n );\n\n return parsed.progress;\n } catch (error) {\n if (error instanceof RegistryBrokerError && error.status === 404) {\n return null;\n }\n throw error;\n }\n}\n\nexport async function waitForRegistrationCompletion(\n client: RegistryBrokerClient,\n attemptId: string,\n options: RegistrationProgressWaitOptions = {},\n): Promise<RegistrationProgressRecord> {\n const normalisedAttemptId = attemptId.trim();\n if (!normalisedAttemptId) {\n throw new Error('attemptId is required');\n }\n\n const interval = Math.max(\n 250,\n options.intervalMs ?? DEFAULT_PROGRESS_INTERVAL_MS,\n );\n const timeoutMs = options.timeoutMs ?? DEFAULT_PROGRESS_TIMEOUT_MS;\n const throwOnFailure = options.throwOnFailure ?? true;\n const signal = options.signal;\n const startedAt = Date.now();\n\n while (true) {\n if (signal?.aborted) {\n throw createAbortError();\n }\n\n const progress = await client.getRegistrationProgress(normalisedAttemptId);\n\n if (progress) {\n options.onProgress?.(progress);\n\n if (progress.status === 'completed') {\n return progress;\n }\n\n if (progress.status === 'partial' || progress.status === 'failed') {\n if (throwOnFailure) {\n throw new RegistryBrokerError(\n 'Registration did not complete successfully',\n {\n status: 409,\n statusText: progress.status,\n body: progress,\n },\n );\n }\n return progress;\n }\n }\n\n if (Date.now() - startedAt >= timeoutMs) {\n throw new Error(\n `Registration progress polling timed out after ${timeoutMs}ms`,\n );\n }\n\n await client.delay(interval, signal);\n }\n}\n\nexport async function validateUaid(\n client: RegistryBrokerClient,\n uaid: string,\n): Promise<UaidValidationResponse> {\n const raw = await client.requestJson<JsonValue>(\n `/uaids/validate/${encodeURIComponent(uaid)}`,\n {\n method: 'GET',\n },\n );\n return client.parseWithSchema(\n raw,\n uaidValidationResponseSchema,\n 'UAID validation response',\n );\n}\n\nexport async function getUaidConnectionStatus(\n client: RegistryBrokerClient,\n uaid: string,\n): Promise<UaidConnectionStatus> {\n const raw = await client.requestJson<JsonValue>(\n `/uaids/connections/${encodeURIComponent(uaid)}/status`,\n {\n method: 'GET',\n },\n );\n return client.parseWithSchema(\n raw,\n uaidConnectionStatusSchema,\n 'UAID connection status',\n );\n}\n\nexport async function closeUaidConnection(\n client: RegistryBrokerClient,\n uaid: string,\n): Promise<void> {\n await client.request(`/uaids/connections/${encodeURIComponent(uaid)}`, {\n method: 'DELETE',\n });\n}\n\nexport async function dashboardStats(\n client: RegistryBrokerClient,\n): Promise<DashboardStatsResponse> {\n const raw = await client.requestJson<JsonValue>('/dashboard/stats', {\n method: 'GET',\n });\n return client.parseWithSchema(\n raw,\n dashboardStatsResponseSchema,\n 'dashboard stats response',\n );\n}\n"],"names":[],"mappings":";;;;AAiCA,eAAe,qBACb,QACA,SACgC;AAChC,QAAM,MAAM,MAAM,OAAO,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sB,oBACpB,QACA,MACe;AACf,QAAM,OAAO,QAAQ,sBAAsB,mBAAmB,IAAI,CAAC,IAAI;AAAA,IACrE,QAAQ;AAAA,EAAA,CACT;AACH;AAEA,eAAsB,eACpB,QACiC;AACjC,QAAM,MAAM,MAAM,OAAO,YAAuB,oBAAoB;AAAA,IAClE,QAAQ;AAAA,EAAA,CACT;AACD,SAAO,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,84 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
const
|
|
3
|
-
let cachedSdk = null;
|
|
4
|
-
const loadHashgraphSdk = () => {
|
|
5
|
-
if (cachedSdk) {
|
|
6
|
-
return cachedSdk;
|
|
7
|
-
}
|
|
8
|
-
const resolved = optionalImportSync("@hashgraph/sdk");
|
|
9
|
-
if (resolved) {
|
|
10
|
-
cachedSdk = resolved;
|
|
11
|
-
return resolved;
|
|
12
|
-
}
|
|
13
|
-
const message = "@hashgraph/sdk is required for ledger signing. Install it as a dependency to enable createPrivateKeySigner.";
|
|
14
|
-
throw new Error(message);
|
|
15
|
-
};
|
|
16
|
-
const loadHashgraphSdkAsync = async () => {
|
|
17
|
-
if (cachedSdk) {
|
|
18
|
-
return cachedSdk;
|
|
19
|
-
}
|
|
20
|
-
const resolved = await optionalImport("@hashgraph/sdk");
|
|
21
|
-
if (resolved) {
|
|
22
|
-
cachedSdk = resolved;
|
|
23
|
-
return resolved;
|
|
24
|
-
}
|
|
25
|
-
const message = "@hashgraph/sdk is required for ledger signing. Install it as a dependency to enable createPrivateKeySigner.";
|
|
26
|
-
throw new Error(message);
|
|
27
|
-
};
|
|
28
|
-
const buildSigner = (sdk, options) => {
|
|
29
|
-
const { AccountId, LedgerId, PrivateKey, SignerSignature } = sdk;
|
|
30
|
-
if (!options.privateKey) {
|
|
31
|
-
throw new Error("privateKey is required to create a ledger signer.");
|
|
32
|
-
}
|
|
33
|
-
if (!options.accountId) {
|
|
34
|
-
throw new Error("accountId is required to create a ledger signer.");
|
|
35
|
-
}
|
|
36
|
-
const accountId = AccountId.fromString(options.accountId);
|
|
37
|
-
const privateKey = PrivateKey.fromString(options.privateKey);
|
|
38
|
-
const ledgerId = LedgerId.fromString(options.network);
|
|
39
|
-
return {
|
|
40
|
-
getLedgerId: () => ledgerId,
|
|
41
|
-
getAccountId: () => accountId,
|
|
42
|
-
getAccountKey: () => privateKey.publicKey,
|
|
43
|
-
getNetwork: () => ({}),
|
|
44
|
-
getMirrorNetwork: () => [],
|
|
45
|
-
sign: async (messages) => Promise.all(
|
|
46
|
-
messages.map(async (message) => {
|
|
47
|
-
const signature = await privateKey.sign(message);
|
|
48
|
-
return new SignerSignature({
|
|
49
|
-
publicKey: privateKey.publicKey,
|
|
50
|
-
signature,
|
|
51
|
-
accountId
|
|
52
|
-
});
|
|
53
|
-
})
|
|
54
|
-
),
|
|
55
|
-
getAccountBalance: async () => {
|
|
56
|
-
throw unsupported("getAccountBalance");
|
|
57
|
-
},
|
|
58
|
-
getAccountInfo: async () => {
|
|
59
|
-
throw unsupported("getAccountInfo");
|
|
60
|
-
},
|
|
61
|
-
getAccountRecords: async () => {
|
|
62
|
-
throw unsupported("getAccountRecords");
|
|
63
|
-
},
|
|
64
|
-
signTransaction: async (_) => {
|
|
65
|
-
throw unsupported("signTransaction");
|
|
66
|
-
},
|
|
67
|
-
checkTransaction: async (_) => {
|
|
68
|
-
throw unsupported("checkTransaction");
|
|
69
|
-
},
|
|
70
|
-
populateTransaction: async (_) => {
|
|
71
|
-
throw unsupported("populateTransaction");
|
|
72
|
-
},
|
|
73
|
-
call: async (_request) => {
|
|
74
|
-
throw unsupported("call");
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
const createPrivateKeySigner = (options) => buildSigner(loadHashgraphSdk(), options);
|
|
79
|
-
const createPrivateKeySignerAsync = async (options) => buildSigner(await loadHashgraphSdkAsync(), options);
|
|
1
|
+
const GUARD_CANONICAL_PATH_PREFIX = "/api/guard";
|
|
2
|
+
const GUARD_COMPAT_PATH_PREFIX = "/guard";
|
|
80
3
|
export {
|
|
81
|
-
|
|
82
|
-
|
|
4
|
+
GUARD_CANONICAL_PATH_PREFIX,
|
|
5
|
+
GUARD_COMPAT_PATH_PREFIX
|
|
83
6
|
};
|
|
84
7
|
//# sourceMappingURL=standards-sdk.es154.js.map
|