@hsuite/smart-engines-sdk 3.13.1 → 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/index.d.ts +72 -2
- package/dist/index.js +149 -2
- package/dist/index.js.map +1 -1
- package/dist/nestjs/index.d.ts +61 -1
- package/dist/nestjs/index.js +126 -2
- package/dist/nestjs/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.14.0 — 2026-06-25
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **Agent + BaaS SDK completeness (from the showcase boundary audit).** Lets app-as-proxy consumers drop hand-rolled raw-fetch workarounds.
|
|
8
|
+
- `AgentsClient.certification(agentId, opts?)` → typed `AgentCertification` (entityId, owner/agent/treasury wallets, primaryChain, rulesHash, BLS group key, state-history topic, recent events + tx ids).
|
|
9
|
+
- `AgentsClient.fund()` now returns the discriminated union `AgentPreparedTransactionResponse | AgentPendingApprovalResponse` (the owner approval-threshold path), plus the `isAgentFundPending()` type guard.
|
|
10
|
+
- `AgentInfo` gains the on-chain DKG identity the host already returns: optional `agentWallet`, `treasuryAccount`, `entityId` (additive).
|
|
11
|
+
- `FunctionsClient.getCode(functionId, opts?)` → `BaasFunctionCode` (`{ functionId, code, codeHash }`) for function source reveal.
|
|
12
|
+
- `StorageClient.downloadWithMeta(cid, opts?)` → `{ bytes, contentType?, filename? }` (the bytes-only `download()` discards the headers), backed by a new `HttpClient.getBinaryWithMeta`.
|
|
13
|
+
- `HttpCallOptions.onBehalfOf` — owner-acting pass-through: forwards an end user's Mode-1 customer-session JWT as BOTH `Authorization: Bearer` and `X-Customer-Session-Claim` (no client-side signing; owner-gated agent routes accept only the Mode-1 JWT — the Mode-2 BLS claim is host-minted and rejected there). Distinct from the metering-only `customerToken`.
|
|
14
|
+
- Error helpers for consumers (e.g. a NestJS exception filter): `SdkHttpError.isRetryable` getter, `isSmartEngineSdkError()` guard, and `toHttpError()` (verbatim mapping with a sub-400 → 502 clamp).
|
|
15
|
+
- **`EntitiesClient.prepareCreateAgent(req)` + `executeCreateAgent(req)` — payer-funded two-phase agent create.** Agent creation now mirrors the account create-flow: the synchronous `createAgent` 400s on payer-funded chains (e.g. `chain=xrpl uses prepare-create / execute-create`), so consumers drive the host's generic two-phase create (`POST /api/v3/baas/entities/prepare-create` + `/execute-create`, `entityType: 'agent'`). `prepareCreateAgent` returns `PreparedEntityCreation` (the unsigned payer-funding tx the dapp signs + submits) and `executeCreateAgent` returns `EntityCreationResult` after the validator finalizes (relaying the signed funding blob on XRPL/Stellar, threading the Hedera `createTxId` receipt). `prepareCreateAgent` remaps the agent's `primaryChain` onto the generic prepare/execute DTO's `chain` key. (#117)
|
|
16
|
+
|
|
3
17
|
## 3.8.0 — 2026-06-17
|
|
4
18
|
|
|
5
19
|
### Added
|
package/dist/index.d.ts
CHANGED
|
@@ -1956,6 +1956,7 @@ export declare class ClusterDiscoveryClient {
|
|
|
1956
1956
|
}
|
|
1957
1957
|
export type HttpCallOptions = {
|
|
1958
1958
|
customerToken?: string;
|
|
1959
|
+
onBehalfOf?: string;
|
|
1959
1960
|
headers?: Record<string, string>;
|
|
1960
1961
|
};
|
|
1961
1962
|
export type HttpClient = {
|
|
@@ -1966,6 +1967,11 @@ export type HttpClient = {
|
|
|
1966
1967
|
delete<T = any>(path: string, opts?: HttpCallOptions): Promise<T>;
|
|
1967
1968
|
getText(path: string, opts?: HttpCallOptions): Promise<string>;
|
|
1968
1969
|
getBinary(path: string, opts?: HttpCallOptions): Promise<Uint8Array>;
|
|
1970
|
+
getBinaryWithMeta(path: string, opts?: HttpCallOptions): Promise<{
|
|
1971
|
+
bytes: Uint8Array;
|
|
1972
|
+
contentType?: string;
|
|
1973
|
+
filename?: string;
|
|
1974
|
+
}>;
|
|
1969
1975
|
upload<T = any>(path: string, file: Blob | Buffer, filename: string, metadata?: Record<string, string>, fieldName?: string, opts?: HttpCallOptions): Promise<T>;
|
|
1970
1976
|
setAuthToken(token: string | undefined): void;
|
|
1971
1977
|
getAuthToken(): string | undefined;
|
|
@@ -1981,6 +1987,7 @@ export declare class SdkHttpError extends Error {
|
|
|
1981
1987
|
readonly statusCode: number;
|
|
1982
1988
|
readonly details?: any | undefined;
|
|
1983
1989
|
constructor(message: string, statusCode: number, details?: any | undefined);
|
|
1990
|
+
get isRetryable(): boolean;
|
|
1984
1991
|
}
|
|
1985
1992
|
export declare function createHttpClient(config: HttpClientConfig): HttpClient;
|
|
1986
1993
|
export declare function encodePathParam(param: string): string;
|
|
@@ -1992,6 +1999,14 @@ export interface RuleRejectedDetails {
|
|
|
1992
1999
|
export declare function isRuleRejected(err: unknown): err is SdkHttpError & {
|
|
1993
2000
|
details: RuleRejectedDetails;
|
|
1994
2001
|
};
|
|
2002
|
+
export declare function isSmartEngineSdkError(err: unknown): err is SdkHttpError;
|
|
2003
|
+
export declare function toHttpError(err: unknown): {
|
|
2004
|
+
statusCode: number;
|
|
2005
|
+
code: string;
|
|
2006
|
+
message: string;
|
|
2007
|
+
isRetryable: boolean;
|
|
2008
|
+
details?: unknown;
|
|
2009
|
+
};
|
|
1995
2010
|
export type DiscoveryClusterEndpoints = {
|
|
1996
2011
|
clusterId: string;
|
|
1997
2012
|
gatewayUrl: string;
|
|
@@ -3839,6 +3854,29 @@ export type AgentInfo = {
|
|
|
3839
3854
|
owner: string;
|
|
3840
3855
|
createdAt: string;
|
|
3841
3856
|
lastActiveAt?: string;
|
|
3857
|
+
agentWallet?: string;
|
|
3858
|
+
treasuryAccount?: string;
|
|
3859
|
+
entityId?: string;
|
|
3860
|
+
};
|
|
3861
|
+
export type AgentCertification = {
|
|
3862
|
+
agentId: string;
|
|
3863
|
+
entityId?: string;
|
|
3864
|
+
ownerWallet?: string;
|
|
3865
|
+
status?: string;
|
|
3866
|
+
agentWallet?: string;
|
|
3867
|
+
treasuryAccount?: string;
|
|
3868
|
+
primaryChain?: string;
|
|
3869
|
+
rulesHash?: string;
|
|
3870
|
+
ruleRef?: string;
|
|
3871
|
+
blsGroupPublicKey?: string;
|
|
3872
|
+
stateHistoryTopicId?: string;
|
|
3873
|
+
recentEvents: Array<{
|
|
3874
|
+
agentId: string;
|
|
3875
|
+
type: string;
|
|
3876
|
+
payload: Record<string, unknown>;
|
|
3877
|
+
timestamp: string;
|
|
3878
|
+
}>;
|
|
3879
|
+
recentTxIds: string[];
|
|
3842
3880
|
};
|
|
3843
3881
|
export type AgentEvent = {
|
|
3844
3882
|
eventId: string;
|
|
@@ -3900,6 +3938,15 @@ export type AgentExecuteResponse = {
|
|
|
3900
3938
|
export type AgentPreparedTransactionResponse = PreparedTransactionResponse & {
|
|
3901
3939
|
success: true;
|
|
3902
3940
|
};
|
|
3941
|
+
export type AgentPendingApprovalResponse = {
|
|
3942
|
+
success: true;
|
|
3943
|
+
pendingOpId: string;
|
|
3944
|
+
agentId: string;
|
|
3945
|
+
action: string;
|
|
3946
|
+
status: "awaiting_approval";
|
|
3947
|
+
description: string;
|
|
3948
|
+
};
|
|
3949
|
+
export declare function isAgentFundPending(r: AgentPreparedTransactionResponse | AgentPendingApprovalResponse): r is AgentPendingApprovalResponse;
|
|
3903
3950
|
export declare class AgentsClient {
|
|
3904
3951
|
private readonly http;
|
|
3905
3952
|
constructor(http: HttpClient);
|
|
@@ -3909,7 +3956,7 @@ export declare class AgentsClient {
|
|
|
3909
3956
|
agents: AgentInfo[];
|
|
3910
3957
|
total: number;
|
|
3911
3958
|
}>;
|
|
3912
|
-
fund(agentId: string, request: AgentFundRequest, opts?: HttpCallOptions): Promise<AgentPreparedTransactionResponse>;
|
|
3959
|
+
fund(agentId: string, request: AgentFundRequest, opts?: HttpCallOptions): Promise<AgentPreparedTransactionResponse | AgentPendingApprovalResponse>;
|
|
3913
3960
|
trade(agentId: string, request: AgentTradeRequest, opts?: HttpCallOptions): Promise<AgentPreparedTransactionResponse>;
|
|
3914
3961
|
withdraw(agentId: string, request: AgentWithdrawRequest, opts?: HttpCallOptions): Promise<AgentPreparedTransactionResponse>;
|
|
3915
3962
|
execute(agentId: string, request: AgentExecuteRequest, opts?: HttpCallOptions): Promise<AgentExecuteResponse & {
|
|
@@ -3927,6 +3974,7 @@ export declare class AgentsClient {
|
|
|
3927
3974
|
success: boolean;
|
|
3928
3975
|
status: string;
|
|
3929
3976
|
}>;
|
|
3977
|
+
certification(agentId: string, opts?: HttpCallOptions): Promise<AgentCertification>;
|
|
3930
3978
|
updateRules(agentId: string, rules: Partial<AgentRules>, opts?: HttpCallOptions): Promise<AgentInfo>;
|
|
3931
3979
|
getEvents(agentId: string, opts?: HttpCallOptions): Promise<{
|
|
3932
3980
|
events: AgentEvent[];
|
|
@@ -4212,6 +4260,11 @@ export type BaasFunctionInfo = {
|
|
|
4212
4260
|
lastInvokedAt?: string;
|
|
4213
4261
|
invocationCount: number;
|
|
4214
4262
|
};
|
|
4263
|
+
export type BaasFunctionCode = {
|
|
4264
|
+
functionId: string;
|
|
4265
|
+
code: string | null;
|
|
4266
|
+
codeHash?: string;
|
|
4267
|
+
};
|
|
4215
4268
|
export type BaasFunctionLog = {
|
|
4216
4269
|
timestamp: string;
|
|
4217
4270
|
level: "debug" | "info" | "warn" | "error";
|
|
@@ -5513,6 +5566,11 @@ export declare class StorageClient {
|
|
|
5513
5566
|
constructor(http: HttpClient, getAppId: () => string);
|
|
5514
5567
|
upload(file: Blob | Buffer, filename: string, metadata?: Record<string, string>, opts?: HttpCallOptions): Promise<BaasUploadResult>;
|
|
5515
5568
|
download(cid: string, opts?: HttpCallOptions): Promise<Uint8Array>;
|
|
5569
|
+
downloadWithMeta(cid: string, opts?: HttpCallOptions): Promise<{
|
|
5570
|
+
bytes: Uint8Array;
|
|
5571
|
+
contentType?: string;
|
|
5572
|
+
filename?: string;
|
|
5573
|
+
}>;
|
|
5516
5574
|
getMetadata(cid: string, opts?: HttpCallOptions): Promise<BaasFileMetadata>;
|
|
5517
5575
|
delete(cid: string, opts?: HttpCallOptions): Promise<{
|
|
5518
5576
|
success: boolean;
|
|
@@ -5543,6 +5601,7 @@ export declare class FunctionsClient {
|
|
|
5543
5601
|
total: number;
|
|
5544
5602
|
}>;
|
|
5545
5603
|
get(functionId: string, opts?: HttpCallOptions): Promise<BaasFunctionInfo>;
|
|
5604
|
+
getCode(functionId: string, opts?: HttpCallOptions): Promise<BaasFunctionCode>;
|
|
5546
5605
|
update(functionId: string, updates: Partial<BaasFunctionDeployRequest>, opts?: HttpCallOptions): Promise<BaasFunctionInfo>;
|
|
5547
5606
|
delete(functionId: string, opts?: HttpCallOptions): Promise<{
|
|
5548
5607
|
success: boolean;
|
|
@@ -25297,6 +25356,9 @@ export type CreateAgentRequest = {
|
|
|
25297
25356
|
ruleRef: RuleRef;
|
|
25298
25357
|
name: string;
|
|
25299
25358
|
agentType?: string;
|
|
25359
|
+
securityMode?: EntitySecurityMode;
|
|
25360
|
+
payerAccountId?: string;
|
|
25361
|
+
fundWith?: FundWith;
|
|
25300
25362
|
};
|
|
25301
25363
|
export type EntityCreationResult = {
|
|
25302
25364
|
entityId: string;
|
|
@@ -25380,6 +25442,14 @@ export declare class EntitiesClient {
|
|
|
25380
25442
|
}): Promise<EntityCreationResult>;
|
|
25381
25443
|
createTopic(req: CreateTopicRequest): Promise<EntityCreationResult>;
|
|
25382
25444
|
createAgent(req: CreateAgentRequest): Promise<EntityCreationResult>;
|
|
25445
|
+
prepareCreateAgent(req: Omit<CreateAgentRequest, "fundWith">): Promise<PreparedEntityCreation>;
|
|
25446
|
+
executeCreateAgent(req: {
|
|
25447
|
+
entityId: string;
|
|
25448
|
+
chain: ChainType;
|
|
25449
|
+
securityMode?: EntitySecurityMode;
|
|
25450
|
+
signedFundingBlob?: string;
|
|
25451
|
+
createTxId?: string;
|
|
25452
|
+
}): Promise<EntityCreationResult>;
|
|
25383
25453
|
launchpad(req: LaunchpadEntityRequest): Promise<LaunchpadEntityResult>;
|
|
25384
25454
|
get(entityId: string): Promise<EntityInfo>;
|
|
25385
25455
|
listByOwner(filter?: ListEntitiesFilter): Promise<ListEntitiesResponse>;
|
|
@@ -25648,7 +25718,7 @@ declare namespace personhood {
|
|
|
25648
25718
|
export { PERSONHOOD_VERIFIER_NOT_CONFIGURED, PersonhoodAttestationMethod, PersonhoodCert, PersonhoodClient, PersonhoodProof, PersonhoodVerifyParams, isPersonhoodVerifierNotConfigured };
|
|
25649
25719
|
}
|
|
25650
25720
|
declare namespace baas {
|
|
25651
|
-
export { AgentBalance, AgentEvent, AgentFundRequest, AgentInfo, AgentOperation, AgentRegisterRequest, AgentRules, AgentRulesValidationResult, AgentStatus, AgentTradeRequest, AgentWithdrawRequest, AgentsClient, AuthenticateOptions, BaasAppListResponse, BaasAuthConfig, BaasAuthResult, BaasChallengeRequest, BaasChallengeResponse, BaasChannelConfig, BaasClient, BaasClientConfig, BaasConnectToClusterConfig, BaasDeleteResult, BaasDeployRequest, BaasDeployResponse, BaasDocument, BaasEndpoints, BaasError, BaasErrorDetails, BaasErrorResponse, BaasFileInfo, BaasFileMetadata, BaasFindResult, BaasFunctionDeployRequest, BaasFunctionDeployResult, BaasFunctionEvalRequest, BaasFunctionInfo, BaasFunctionLog, BaasFunctionLogOptions, BaasFunctionResources, BaasFunctionResult, BaasFunctionRuntime, BaasHistoryOptions, BaasInitRequest, BaasInitResponse, BaasInsertResult, BaasMerkleProof, BaasMessage, BaasPresenceInfo, BaasPresenceMember, BaasPublishResult, BaasQueryOptions, BaasReissuePushCredentialsResponse, BaasRevokeKekResponse, BaasRollbackRequest, BaasRotateKekResponse, BaasRuntimeStatus, BaasService, BaasSessionInfo, BaasSetWebhookResponse, BaasSignedCode, BaasStateTransition, BaasStorageUsage, BaasSupportedChain, BaasTriggerType, BaasUpdateResult, BaasUploadFrontendResponse, BaasUploadResult, BaasVerifyRequest, ChannelSubscription, CreateAccountRequest$1 as BaasCreateAccountRequest, CreateAgentRequest, CreateTokenRequest$1 as CreateTokenRequest, CreateTopicRequest, DatabaseClient, DatabaseStatsResponse, DbComparisonOperator, DbDocument, DbQuery, DeployedApp, DeployedAppInfo, DeployedAppLimits, DeployedAppStatus, DeployedAppUsage, DeploymentClient, DeprecateRuleResponse, DocumentProofResponse, EntitiesClient, EntityCreationResult, EntityInfo, EntitySecurityMode, EntityType$1 as BaasEntityType, FunctionsClient, FundWith, LaunchpadEntityRequest, LaunchpadEntityResult, ListEntitiesFilter, ListEntitiesResponse, ListRulesFilter, ListRulesResponse, MessageHandler, MessagingClient, PreparedEntityCreation, PublishRuleResponse, RulesClient, SimulateRuleRequest, StateRootResponse, StateTransitionsResponse, StorageClient, ValidationResult, VersionHistoryResponse, validateAgentRules };
|
|
25721
|
+
export { AgentBalance, AgentCertification, AgentEvent, AgentFundRequest, AgentInfo, AgentOperation, AgentPendingApprovalResponse, AgentPreparedTransactionResponse, AgentRegisterRequest, AgentRules, AgentRulesValidationResult, AgentStatus, AgentTradeRequest, AgentWithdrawRequest, AgentsClient, AuthenticateOptions, BaasAppListResponse, BaasAuthConfig, BaasAuthResult, BaasChallengeRequest, BaasChallengeResponse, BaasChannelConfig, BaasClient, BaasClientConfig, BaasConnectToClusterConfig, BaasDeleteResult, BaasDeployRequest, BaasDeployResponse, BaasDocument, BaasEndpoints, BaasError, BaasErrorDetails, BaasErrorResponse, BaasFileInfo, BaasFileMetadata, BaasFindResult, BaasFunctionCode, BaasFunctionDeployRequest, BaasFunctionDeployResult, BaasFunctionEvalRequest, BaasFunctionInfo, BaasFunctionLog, BaasFunctionLogOptions, BaasFunctionResources, BaasFunctionResult, BaasFunctionRuntime, BaasHistoryOptions, BaasInitRequest, BaasInitResponse, BaasInsertResult, BaasMerkleProof, BaasMessage, BaasPresenceInfo, BaasPresenceMember, BaasPublishResult, BaasQueryOptions, BaasReissuePushCredentialsResponse, BaasRevokeKekResponse, BaasRollbackRequest, BaasRotateKekResponse, BaasRuntimeStatus, BaasService, BaasSessionInfo, BaasSetWebhookResponse, BaasSignedCode, BaasStateTransition, BaasStorageUsage, BaasSupportedChain, BaasTriggerType, BaasUpdateResult, BaasUploadFrontendResponse, BaasUploadResult, BaasVerifyRequest, ChannelSubscription, CreateAccountRequest$1 as BaasCreateAccountRequest, CreateAgentRequest, CreateTokenRequest$1 as CreateTokenRequest, CreateTopicRequest, DatabaseClient, DatabaseStatsResponse, DbComparisonOperator, DbDocument, DbQuery, DeployedApp, DeployedAppInfo, DeployedAppLimits, DeployedAppStatus, DeployedAppUsage, DeploymentClient, DeprecateRuleResponse, DocumentProofResponse, EntitiesClient, EntityCreationResult, EntityInfo, EntitySecurityMode, EntityType$1 as BaasEntityType, FunctionsClient, FundWith, LaunchpadEntityRequest, LaunchpadEntityResult, ListEntitiesFilter, ListEntitiesResponse, ListRulesFilter, ListRulesResponse, MessageHandler, MessagingClient, PreparedEntityCreation, PublishRuleResponse, RulesClient, SimulateRuleRequest, StateRootResponse, StateTransitionsResponse, StorageClient, ValidationResult, VersionHistoryResponse, isAgentFundPending, validateAgentRules };
|
|
25652
25722
|
}
|
|
25653
25723
|
declare namespace pqcVerify {
|
|
25654
25724
|
export { FetchRegistryOptions, PqcCertV1, PqcCertV1Schema, PqcCertV1Signer, ValidatorRegistrySnapshot, VerifyResult, fetchRegistrySnapshot, parsePqcCert, verifyPqcAttestation };
|
package/dist/index.js
CHANGED
|
@@ -6606,6 +6606,13 @@ var SdkHttpError = class extends Error {
|
|
|
6606
6606
|
}
|
|
6607
6607
|
statusCode;
|
|
6608
6608
|
details;
|
|
6609
|
+
/**
|
|
6610
|
+
* True for transient failures worth retrying: a 5xx, a 429 (rate limit), a 408
|
|
6611
|
+
* (timeout), or a 0 (network/abort). Deterministic 4xx client errors are not.
|
|
6612
|
+
*/
|
|
6613
|
+
get isRetryable() {
|
|
6614
|
+
return this.statusCode === 0 || this.statusCode === 408 || this.statusCode === 429 || this.statusCode >= 500;
|
|
6615
|
+
}
|
|
6609
6616
|
};
|
|
6610
6617
|
function createHttpClient(config) {
|
|
6611
6618
|
const timeout = config.timeout ?? 3e4;
|
|
@@ -6623,6 +6630,10 @@ function createHttpClient(config) {
|
|
|
6623
6630
|
if (opts?.customerToken) {
|
|
6624
6631
|
headers["X-Customer-Session-Token"] = opts.customerToken;
|
|
6625
6632
|
}
|
|
6633
|
+
if (opts?.onBehalfOf) {
|
|
6634
|
+
headers["Authorization"] = `Bearer ${opts.onBehalfOf}`;
|
|
6635
|
+
headers["X-Customer-Session-Claim"] = opts.onBehalfOf;
|
|
6636
|
+
}
|
|
6626
6637
|
if (opts?.headers) {
|
|
6627
6638
|
Object.assign(headers, opts.headers);
|
|
6628
6639
|
}
|
|
@@ -6730,6 +6741,41 @@ function createHttpClient(config) {
|
|
|
6730
6741
|
throw new SdkHttpError(`Network error: ${err.message}`, 0, error);
|
|
6731
6742
|
}
|
|
6732
6743
|
}
|
|
6744
|
+
async function getBinaryWithMeta(path, opts) {
|
|
6745
|
+
const url = `${config.baseUrl}${path}`;
|
|
6746
|
+
const controller = new AbortController();
|
|
6747
|
+
const timeoutId = setTimeout(() => controller.abort(), timeout);
|
|
6748
|
+
try {
|
|
6749
|
+
const response = await fetch(url, {
|
|
6750
|
+
method: "GET",
|
|
6751
|
+
headers: getHeaders(void 0, opts),
|
|
6752
|
+
signal: controller.signal
|
|
6753
|
+
});
|
|
6754
|
+
clearTimeout(timeoutId);
|
|
6755
|
+
if (!response.ok) {
|
|
6756
|
+
const errBody = await response.json().catch(() => ({}));
|
|
6757
|
+
throw new SdkHttpError(
|
|
6758
|
+
errBody.message || `API error: ${response.status} ${response.statusText}`,
|
|
6759
|
+
response.status,
|
|
6760
|
+
errBody
|
|
6761
|
+
);
|
|
6762
|
+
}
|
|
6763
|
+
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
6764
|
+
const contentType = response.headers.get("content-type") ?? void 0;
|
|
6765
|
+
const disposition = response.headers.get("content-disposition") ?? "";
|
|
6766
|
+
const match = /filename\*?=(?:UTF-8'')?"?([^"\n;]+)"?/i.exec(disposition);
|
|
6767
|
+
const filename = match ? decodeURIComponent(match[1].trim()) : void 0;
|
|
6768
|
+
return { bytes, contentType, filename };
|
|
6769
|
+
} catch (error) {
|
|
6770
|
+
clearTimeout(timeoutId);
|
|
6771
|
+
if (error instanceof SdkHttpError) throw error;
|
|
6772
|
+
const err = error;
|
|
6773
|
+
if (err.name === "AbortError") {
|
|
6774
|
+
throw new SdkHttpError("Request timeout", 408);
|
|
6775
|
+
}
|
|
6776
|
+
throw new SdkHttpError(`Network error: ${err.message}`, 0, error);
|
|
6777
|
+
}
|
|
6778
|
+
}
|
|
6733
6779
|
async function upload(path, file, filename, metadata, fieldName = "file", opts) {
|
|
6734
6780
|
const url = `${config.baseUrl}${path}`;
|
|
6735
6781
|
const controller = new AbortController();
|
|
@@ -6753,6 +6799,10 @@ function createHttpClient(config) {
|
|
|
6753
6799
|
if (opts?.customerToken) {
|
|
6754
6800
|
headers["X-Customer-Session-Token"] = opts.customerToken;
|
|
6755
6801
|
}
|
|
6802
|
+
if (opts?.onBehalfOf) {
|
|
6803
|
+
headers["Authorization"] = `Bearer ${opts.onBehalfOf}`;
|
|
6804
|
+
headers["X-Customer-Session-Claim"] = opts.onBehalfOf;
|
|
6805
|
+
}
|
|
6756
6806
|
if (opts?.headers) {
|
|
6757
6807
|
Object.assign(headers, opts.headers);
|
|
6758
6808
|
}
|
|
@@ -6810,6 +6860,7 @@ function createHttpClient(config) {
|
|
|
6810
6860
|
delete: (path, opts) => withAuthRetry(path, () => request("DELETE", path, void 0, opts)),
|
|
6811
6861
|
getText: (path, opts) => withAuthRetry(path, () => getText(path, opts)),
|
|
6812
6862
|
getBinary: (path, opts) => withAuthRetry(path, () => getBinary(path, opts)),
|
|
6863
|
+
getBinaryWithMeta: (path, opts) => withAuthRetry(path, () => getBinaryWithMeta(path, opts)),
|
|
6813
6864
|
upload: ((path, file, filename, metadata, fieldName, opts) => withAuthRetry(path, () => upload(path, file, filename, metadata, fieldName, opts))),
|
|
6814
6865
|
setAuthToken,
|
|
6815
6866
|
getAuthToken
|
|
@@ -6830,6 +6881,22 @@ function isRuleRejected(err) {
|
|
|
6830
6881
|
if (!Array.isArray(obj.ruleAtoms)) return false;
|
|
6831
6882
|
return obj.ruleAtoms.every((a) => typeof a === "string");
|
|
6832
6883
|
}
|
|
6884
|
+
function isSmartEngineSdkError(err) {
|
|
6885
|
+
return err instanceof SdkHttpError;
|
|
6886
|
+
}
|
|
6887
|
+
function toHttpError(err) {
|
|
6888
|
+
if (isSmartEngineSdkError(err)) {
|
|
6889
|
+
return {
|
|
6890
|
+
statusCode: err.statusCode >= 400 ? err.statusCode : 502,
|
|
6891
|
+
code: "SDK_HTTP_ERROR",
|
|
6892
|
+
message: err.message,
|
|
6893
|
+
isRetryable: err.isRetryable,
|
|
6894
|
+
details: err.details
|
|
6895
|
+
};
|
|
6896
|
+
}
|
|
6897
|
+
const message = err instanceof Error ? err.message : "Unknown error";
|
|
6898
|
+
return { statusCode: 500, code: "INTERNAL_ERROR", message, isRetryable: false };
|
|
6899
|
+
}
|
|
6833
6900
|
|
|
6834
6901
|
// src/discovery/discovery-client.ts
|
|
6835
6902
|
var DiscoveryClient = class {
|
|
@@ -8567,6 +8634,9 @@ function isPositiveDecimalString(value) {
|
|
|
8567
8634
|
}
|
|
8568
8635
|
|
|
8569
8636
|
// src/baas/agents/index.ts
|
|
8637
|
+
function isAgentFundPending(r) {
|
|
8638
|
+
return "pendingOpId" in r;
|
|
8639
|
+
}
|
|
8570
8640
|
var AgentsClient = class {
|
|
8571
8641
|
constructor(http) {
|
|
8572
8642
|
this.http = http;
|
|
@@ -8585,9 +8655,12 @@ var AgentsClient = class {
|
|
|
8585
8655
|
return this.http.get("/api/v3/baas/agents", opts);
|
|
8586
8656
|
}
|
|
8587
8657
|
/**
|
|
8588
|
-
* Fund agent treasury (owner-only).
|
|
8658
|
+
* Fund agent treasury (owner-only). Normally returns a
|
|
8589
8659
|
* `PreparedTransactionResponse` wrapped in a `success: true` envelope —
|
|
8590
|
-
* the caller is expected to sign and submit the prepared bytes.
|
|
8660
|
+
* the caller is expected to sign and submit the prepared bytes. When the
|
|
8661
|
+
* amount trips an approval-required rule the host instead returns an
|
|
8662
|
+
* {@link AgentPendingApprovalResponse}; discriminate with
|
|
8663
|
+
* {@link isAgentFundPending}.
|
|
8591
8664
|
*/
|
|
8592
8665
|
async fund(agentId, request, opts) {
|
|
8593
8666
|
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/fund`, request, opts);
|
|
@@ -8626,6 +8699,14 @@ var AgentsClient = class {
|
|
|
8626
8699
|
async revoke(agentId, opts) {
|
|
8627
8700
|
return this.http.post(`/api/v3/baas/agents/${encodePathParam(agentId)}/revoke`, {}, opts);
|
|
8628
8701
|
}
|
|
8702
|
+
/**
|
|
8703
|
+
* Get an agent's certification snapshot (identity, rule refs, BLS group key,
|
|
8704
|
+
* and recent on-chain activity). A 404 throws `SdkHttpError` via `http.get`
|
|
8705
|
+
* — parity with {@link get}.
|
|
8706
|
+
*/
|
|
8707
|
+
async certification(agentId, opts) {
|
|
8708
|
+
return this.http.get(`/api/v3/baas/agents/${encodePathParam(agentId)}/certification`, opts);
|
|
8709
|
+
}
|
|
8629
8710
|
/**
|
|
8630
8711
|
* Update agent rules.
|
|
8631
8712
|
*
|
|
@@ -10743,6 +10824,7 @@ __export(baas_exports, {
|
|
|
10743
10824
|
MessagingClient: () => MessagingClient,
|
|
10744
10825
|
RulesClient: () => RulesClient,
|
|
10745
10826
|
StorageClient: () => StorageClient,
|
|
10827
|
+
isAgentFundPending: () => isAgentFundPending,
|
|
10746
10828
|
validateAgentRules: () => validateAgentRules
|
|
10747
10829
|
});
|
|
10748
10830
|
|
|
@@ -10896,6 +10978,20 @@ var StorageClient = class {
|
|
|
10896
10978
|
const appId = this.getAppId();
|
|
10897
10979
|
return this.http.getBinary(`/api/v3/baas/storage/${encodePathParam(appId)}/download/${encodePathParam(cid)}`, opts);
|
|
10898
10980
|
}
|
|
10981
|
+
/**
|
|
10982
|
+
* Download a file by CID WITH its response metadata — the raw bytes plus the
|
|
10983
|
+
* host-supplied `contentType` (derived from the stored file's metadata) and,
|
|
10984
|
+
* when present, the `filename`. Use this instead of {@link download} when the
|
|
10985
|
+
* caller must echo the content-type back to its own client; a bytes-only
|
|
10986
|
+
* download cannot recover it.
|
|
10987
|
+
*/
|
|
10988
|
+
async downloadWithMeta(cid, opts) {
|
|
10989
|
+
const appId = this.getAppId();
|
|
10990
|
+
return this.http.getBinaryWithMeta(
|
|
10991
|
+
`/api/v3/baas/storage/${encodePathParam(appId)}/download/${encodePathParam(cid)}`,
|
|
10992
|
+
opts
|
|
10993
|
+
);
|
|
10994
|
+
}
|
|
10899
10995
|
/**
|
|
10900
10996
|
* Get file metadata
|
|
10901
10997
|
*/
|
|
@@ -11018,6 +11114,16 @@ var FunctionsClient = class {
|
|
|
11018
11114
|
opts
|
|
11019
11115
|
);
|
|
11020
11116
|
}
|
|
11117
|
+
/**
|
|
11118
|
+
* Get a function's source code
|
|
11119
|
+
*/
|
|
11120
|
+
async getCode(functionId, opts) {
|
|
11121
|
+
const appId = this.getAppId();
|
|
11122
|
+
return this.http.get(
|
|
11123
|
+
`/api/v3/baas/functions/${encodePathParam(appId)}/${encodePathParam(functionId)}/code`,
|
|
11124
|
+
opts
|
|
11125
|
+
);
|
|
11126
|
+
}
|
|
11021
11127
|
/**
|
|
11022
11128
|
* Update a function
|
|
11023
11129
|
*/
|
|
@@ -11599,6 +11705,44 @@ var EntitiesClient = class _EntitiesClient {
|
|
|
11599
11705
|
async createAgent(req) {
|
|
11600
11706
|
return this.http.post("/api/v3/baas/entities/createAgent", req);
|
|
11601
11707
|
}
|
|
11708
|
+
/**
|
|
11709
|
+
* PREPARE half of the payer-funded agent-create flow.
|
|
11710
|
+
*
|
|
11711
|
+
* POSTs `/api/v3/baas/entities/prepare-create` with `entityType: 'agent'`. The cluster
|
|
11712
|
+
* runs the per-entity DKG (persists the binding, submits nothing on-chain) and
|
|
11713
|
+
* returns the unsigned payer-funding `Payment`(s) the caller signs + submits with
|
|
11714
|
+
* their own wallet — mirroring `prepareCreateAccount`. The agent's primary chain
|
|
11715
|
+
* is relayed as `chain` (the generic prepare/execute DTO key) so the host's
|
|
11716
|
+
* chain-bound preparer runs; `name` / `agentType` / `ruleRef` ride along.
|
|
11717
|
+
*/
|
|
11718
|
+
async prepareCreateAgent(req) {
|
|
11719
|
+
const { primaryChain, ...rest } = req;
|
|
11720
|
+
return this.http.post("/api/v3/baas/entities/prepare-create", {
|
|
11721
|
+
entityType: "agent",
|
|
11722
|
+
chain: primaryChain,
|
|
11723
|
+
...rest
|
|
11724
|
+
});
|
|
11725
|
+
}
|
|
11726
|
+
/**
|
|
11727
|
+
* EXECUTE half of the payer-funded agent-create flow.
|
|
11728
|
+
*
|
|
11729
|
+
* POSTs `/api/v3/baas/entities/execute-create` with `entityType: 'agent'`. The entity
|
|
11730
|
+
* already exists (its DKG ran during prepare); pass `signedFundingBlob` for the
|
|
11731
|
+
* validator to submit the payer's signed funding tx (XRPL/Stellar account-model
|
|
11732
|
+
* relay), or omit it when the caller already submitted the funding tx themselves.
|
|
11733
|
+
* `createTxId` is the Hedera receipt thread (the prepared create's
|
|
11734
|
+
* `transactionId`); ignored for non-Hedera chains. Mirrors
|
|
11735
|
+
* `executeCreateAccount` but tags `entityType: 'agent'`.
|
|
11736
|
+
*/
|
|
11737
|
+
async executeCreateAgent(req) {
|
|
11738
|
+
const { createTxId, signedFundingBlob, ...rest } = req;
|
|
11739
|
+
return this.http.post("/api/v3/baas/entities/execute-create", {
|
|
11740
|
+
...rest,
|
|
11741
|
+
...createTxId !== void 0 ? { createTxId } : {},
|
|
11742
|
+
...signedFundingBlob !== void 0 ? { signedFundingBlob } : {},
|
|
11743
|
+
entityType: "agent"
|
|
11744
|
+
});
|
|
11745
|
+
}
|
|
11602
11746
|
/**
|
|
11603
11747
|
* Mega-helper: build a token rule with a launchpad ModuleEntry attached,
|
|
11604
11748
|
* publish it, create the token, and return the combined result in one HTTP
|
|
@@ -13886,9 +14030,11 @@ exports.forToken = forToken;
|
|
|
13886
14030
|
exports.forTopic = forTopic;
|
|
13887
14031
|
exports.governance = governance_exports;
|
|
13888
14032
|
exports.inferJson = inferJson;
|
|
14033
|
+
exports.isAgentFundPending = isAgentFundPending;
|
|
13889
14034
|
exports.isKnownNetwork = isKnownNetwork;
|
|
13890
14035
|
exports.isPersonhoodVerifierNotConfigured = isPersonhoodVerifierNotConfigured;
|
|
13891
14036
|
exports.isRuleRejected = isRuleRejected;
|
|
14037
|
+
exports.isSmartEngineSdkError = isSmartEngineSdkError;
|
|
13892
14038
|
exports.managedAccount = managedAccount;
|
|
13893
14039
|
exports.membershipNft = membershipNft;
|
|
13894
14040
|
exports.module_ = module_;
|
|
@@ -13912,6 +14058,7 @@ exports.subscriptionNft = subscriptionNft;
|
|
|
13912
14058
|
exports.systemTopic = systemTopic;
|
|
13913
14059
|
exports.template = template;
|
|
13914
14060
|
exports.tieredIDO = tieredIDO;
|
|
14061
|
+
exports.toHttpError = toHttpError;
|
|
13915
14062
|
exports.tokenDAO = tokenDAO;
|
|
13916
14063
|
exports.tokens = tokens_exports;
|
|
13917
14064
|
exports.tradingAgent = tradingAgent;
|