@terminal3/t3n-sdk 4.14.0 → 4.16.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/dist/index.d.ts CHANGED
@@ -2007,17 +2007,42 @@ declare class T3nClient {
2007
2007
  * returned exactly once here and is never persisted or recoverable
2008
2008
  * afterwards, so the caller must capture it immediately.
2009
2009
  *
2010
+ * Atomic registration + card hosting: pass `options.agentUri` and the
2011
+ * SAME transaction also writes the agent-registry record (URI + the
2012
+ * org's publish-consent link, born together) and — unless
2013
+ * `options.defaultCard === false` — hosts a PRIVATE card for the new
2014
+ * agent in the org's `agent-cards` scope. The card body is
2015
+ * `options.card` when given (object or pre-serialised JSON string);
2016
+ * otherwise the CONTRACT builds and hosts its default (which can even
2017
+ * name the agent DID, minted inside the same transaction).
2018
+ *
2019
+ * The card is deliberately NOT published: an org-bound agent must not
2020
+ * become world-discoverable as a side effect of provisioning. Publish
2021
+ * explicitly with `agentCardPublish` (one call — the consent link
2022
+ * already exists from creation). All-or-nothing: any refusal creates
2023
+ * no agent, no record, no card.
2024
+ *
2010
2025
  * @param organisationDid - the owning organisation's DID
2011
2026
  * (`did:t3n:<40-hex>`); the caller must be one of its admins
2012
2027
  * @param name - human-readable agent name (1..=128 bytes)
2013
- * @returns the new agent's DID and its one-time private key
2028
+ * @param options - optional atomic registration + card hosting
2029
+ * @returns the new agent's DID and its one-time private key, plus
2030
+ * `agentUri` / `cardEntryId` (the hosted PRIVATE card's entry id)
2031
+ * when the atomic path ran
2014
2032
  * @throws if the session is not authenticated, or if the contract
2015
- * refuses (e.g. the caller is not an admin of `organisationDid`, or the
2016
- * name is empty / too long)
2017
- */
2018
- createAgent(organisationDid: string, name: string): Promise<{
2033
+ * refuses (e.g. the caller is not an admin of `organisationDid`, the
2034
+ * name is empty / too long, or the card fails validation — in which
2035
+ * case NOTHING was created)
2036
+ */
2037
+ createAgent(organisationDid: string, name: string, options?: {
2038
+ agentUri?: string;
2039
+ card?: object | string;
2040
+ defaultCard?: boolean;
2041
+ }): Promise<{
2019
2042
  agentDid: Did;
2020
2043
  privateKey: string;
2044
+ agentUri?: string;
2045
+ cardEntryId?: string;
2021
2046
  }>;
2022
2047
  /**
2023
2048
  * Read the authenticated user's own agent-auth policy — the standing
@@ -2706,13 +2731,6 @@ interface UserGrant {
2706
2731
  functions: string[];
2707
2732
  /** Data scope paths the user may access (e.g. `"example/records"`). */
2708
2733
  scopes: string[];
2709
- /**
2710
- * Optional key-value constraints that must match the request metadata
2711
- * exactly for every key present in this map.
2712
- */
2713
- constraints: Record<string, string>;
2714
- /** Unix timestamp (secs) after which this grant is expired. `null` means never expires. */
2715
- expires_at_secs: number | null;
2716
2734
  }
2717
2735
  /**
2718
2736
  * Policy record for an organisation's data tier.
@@ -2780,7 +2798,10 @@ declare function isOrgAdminStatus(value: unknown): value is OrgAdminStatus;
2780
2798
  * Mirrors the org-data `MutationResponse` wire shape.
2781
2799
  */
2782
2800
  interface MutationResponse {
2783
- /** `"created"`, `"updated"`, or `"deleted"`. */
2801
+ /**
2802
+ * `"created"`, `"updated"`, `"deleted"`, or — for the agent-card mutations —
2803
+ * `"published"` / `"unpublished"`.
2804
+ */
2784
2805
  status: string;
2785
2806
  /** Hex-encoded entry ID; present on data write/delete operations. */
2786
2807
  entry_id?: string;
@@ -2847,6 +2868,20 @@ interface DataGetResponse {
2847
2868
  }
2848
2869
  /** Shallow runtime guard for {@link DataGetResponse}. */
2849
2870
  declare function isDataGetResponse(value: unknown): value is DataGetResponse;
2871
+ /**
2872
+ * Return shape of `agentCardGet` — composed client-side from the generic
2873
+ * `org-data-get` read of the card's entry (there is no card-specific read
2874
+ * operation on the contract). To check whether a public copy exists, probe
2875
+ * the anonymous `GET /api/agent-card/{did}` endpoint.
2876
+ */
2877
+ interface AgentCardResponse {
2878
+ /** The agent whose card this is (`did:t3n:<40-hex>`). */
2879
+ agent_did: string;
2880
+ /** The stored card JSON body, verbatim. */
2881
+ card: string;
2882
+ }
2883
+ /** Shallow runtime guard for {@link AgentCardResponse}. */
2884
+ declare function isAgentCardResponse(value: unknown): value is AgentCardResponse;
2850
2885
  /**
2851
2886
  * Legacy direct-route org-data envelope shape retained for compatibility.
2852
2887
  *
@@ -2883,6 +2918,21 @@ interface OrgDataActionWire {
2883
2918
  * constructing one-shot signed HTTP envelopes per call.
2884
2919
  */
2885
2920
 
2921
+ /**
2922
+ * Org-data scope agent cards are stored under. The private card body is
2923
+ * ordinary org-data — written / read / deleted with the generic
2924
+ * `org-data-*` operations under this scope; only publication has dedicated
2925
+ * contract operations.
2926
+ */
2927
+ declare const AGENT_CARDS_SCOPE = "agent-cards";
2928
+ /**
2929
+ * Derive the canonical org-data entry ID an agent card is stored under:
2930
+ * the first 16 bytes of `SHA-256(owner ‖ "agent-cards" ‖ agent ‖ u64_be(0))`
2931
+ * — byte-identical to the contract's `derive_entry_id(owner, "agent-cards",
2932
+ * agent, 0)`, so `agent-card-publish` finds the entry without a reverse
2933
+ * lookup. Returned as 32 lowercase hex chars (the wire `entry_id` format).
2934
+ */
2935
+ declare function deriveAgentCardEntryId(ownerDid: string, agentDid: string): string;
2886
2936
  interface CreatePolicyInput {
2887
2937
  orgDid: string;
2888
2938
  initialAdminDid: string;
@@ -2996,6 +3046,27 @@ interface DataGetInput {
2996
3046
  /** Hex-encoded entry ID (32 hex chars). */
2997
3047
  entryId: string;
2998
3048
  }
3049
+ interface AgentCardSetInput {
3050
+ /**
3051
+ * The card owner (`did:t3n:<40-hex>`) — an org DID (written by its
3052
+ * `agent-cards` scope writers) or an individual/agent DID (a self-owned
3053
+ * data space: the owner itself writes, no org needed).
3054
+ */
3055
+ ownerDid: string;
3056
+ /** The agent whose card this is (`did:t3n:<40-hex>`). */
3057
+ agentDid: string;
3058
+ /**
3059
+ * Full card JSON body. Validated locally (non-empty / ≤ 16 KiB / JSON) —
3060
+ * the same gate the contract applies at publish time.
3061
+ */
3062
+ card: string;
3063
+ }
3064
+ /** Reference to a single agent's card by `(owner, agent)`. */
3065
+ interface AgentCardRefInput {
3066
+ /** The card owner — an org DID or an individual/agent DID. */
3067
+ ownerDid: string;
3068
+ agentDid: string;
3069
+ }
2999
3070
  interface ExecuteOrgDataActionOptions {
3000
3071
  /**
3001
3072
  * Deprecated. The direct signed-envelope transport used this as the
@@ -3143,6 +3214,33 @@ declare class OrgDataClient {
3143
3214
  dataList(input: DataListInput): Promise<DataListResponse>;
3144
3215
  /** Retrieve a single data entry by entry ID (admin-only). */
3145
3216
  dataGet(input: DataGetInput): Promise<DataGetResponse>;
3217
+ /**
3218
+ * Create or overwrite an agent's private card (org scope-writer, or the
3219
+ * owner itself for a self-owned space). Validates locally with the same
3220
+ * gate the contract applies at publish. The card stays private until
3221
+ * {@link agentCardPublish}.
3222
+ */
3223
+ agentCardSet(input: AgentCardSetInput): Promise<MutationResponse>;
3224
+ /**
3225
+ * Delete an agent's private card. Does NOT unpublish — publication is
3226
+ * explicit state; call {@link agentCardUnpublish} to retract the public copy.
3227
+ */
3228
+ agentCardDelete(input: AgentCardRefInput): Promise<MutationResponse>;
3229
+ /**
3230
+ * Publish an agent's card to the world-readable `public:agent_cards` map
3231
+ * (served at `GET /api/agent-card/{did}`). The contract validates the
3232
+ * stored bytes, then byte-copies them. Publishing under a third-party
3233
+ * agent DID requires the agent's registry record to name this owner
3234
+ * (consent link); implicit when the owner IS the agent.
3235
+ */
3236
+ agentCardPublish(input: AgentCardRefInput): Promise<MutationResponse>;
3237
+ /** Remove an agent's card from `public:agent_cards`. */
3238
+ agentCardUnpublish(input: AgentCardRefInput): Promise<MutationResponse>;
3239
+ /**
3240
+ * Read an agent's private card (org: admin or delegation-credential holder
3241
+ * for the `agent-cards` scope; self-owned: the owner).
3242
+ */
3243
+ agentCardGet(input: AgentCardRefInput): Promise<AgentCardResponse>;
3146
3244
  }
3147
3245
  /**
3148
3246
  * Session-authenticated variant of {@link OrgDataClient}.
@@ -3215,6 +3313,16 @@ declare class SessionOrgDataClient {
3215
3313
  dataList(input: DataListInput): Promise<DataListResponse>;
3216
3314
  /** Mirrors {@link OrgDataClient.dataGet}. */
3217
3315
  dataGet(input: DataGetInput): Promise<DataGetResponse>;
3316
+ /** Mirrors {@link OrgDataClient.agentCardSet}. */
3317
+ agentCardSet(input: AgentCardSetInput): Promise<MutationResponse>;
3318
+ /** Mirrors {@link OrgDataClient.agentCardDelete}. */
3319
+ agentCardDelete(input: AgentCardRefInput): Promise<MutationResponse>;
3320
+ /** Mirrors {@link OrgDataClient.agentCardPublish}. */
3321
+ agentCardPublish(input: AgentCardRefInput): Promise<MutationResponse>;
3322
+ /** Mirrors {@link OrgDataClient.agentCardUnpublish}. */
3323
+ agentCardUnpublish(input: AgentCardRefInput): Promise<MutationResponse>;
3324
+ /** Mirrors {@link OrgDataClient.agentCardGet}. */
3325
+ agentCardGet(input: AgentCardRefInput): Promise<AgentCardResponse>;
3218
3326
  }
3219
3327
  /**
3220
3328
  * Construct a {@link SessionOrgDataClient} from a caller-owned
@@ -4028,5 +4136,5 @@ declare function tenantDidHex(tenantDid: string): string;
4028
4136
  declare function validateTail(tail: string): string;
4029
4137
  declare function canonicalTenantName(tenantDid: string, tail: string): string;
4030
4138
 
4031
- export { AuthMethod, AuthenticationError, BASE_UNITS_PER_TOKEN, ContractResponseError, DEFAULT_ENVIRONMENT, DEFAULT_INDIVIDUAL_THRESHOLD_CENTS, DEFAULT_KYC_POLL_CADENCE, HandshakeError, HttpTransport, KycStatusTimeoutError, LogLevel, MockTransport, NODE_URLS, OrgDataClient, OtpRateLimitedError, RpcError, SessionExpiredError, SessionOrgDataClient, SessionStateError, SessionStatus, SessionUsageReportClient, T3nClient, T3nError, TERMINAL_KYC_STATUSES, TOKEN_DECIMALS, TenantClient, TenantContractsNamespace, TenantMapsNamespace, TenantNamespace, TenantSdkValidationError, TenantTokenNamespace, UnsupportedTenantSdkOperationError, UserUpsertError, WasmError, WireEncodingError, Z_PAYROLL_AUDIT_READ_FUNCTIONS, Z_PAYROLL_RUN_FUNCTIONS, _b64uEncode, assertShape, b64uDecodeStrict, b64uEncodeBytes, bytesToString, canonicalTenantName, clearKeyCache, compactDidFromBytes, createDefaultHandlers, createEmailOtpAuthInput, createEthAuthInput, createLogger, createMlKemPublicKeyHandler, createOidcAuthInput, createOrgDataClientFromSession, createRandomHandler, createUsageReportClientFromSession, createWorkloadAuthInput, decodeWasmErrorMessage, eth_get_address, extractWasmError, fetchDkgAttestation, fetchMlKemPublicKey, formatTokens, generateRandomString, generateUUID, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger, getNodeUrl, getScriptVersion, isDataGetResponse, isDataListResponse, isMutationResponse, isObject, isOrgAdminStatus, isOrgContractGrants, isOrgPolicyMeta, isOrgPolicyView, isOrgUsageReport, isOrgWriters, isUnsafeTrustServer, loadConfig, loadWasmComponent, maskKeyMaterial, mergeAgentAuthEntries, mergeDiscoverDids, metamask_get_address, metamask_sign, parseAgentAuthGet, parseAgentAuthPolicy, parseContractResponse, redactSecrets, redactSecretsFromJson, requestToWire, setEnvironment, setGlobalLogLevel, setNodeUrl, stringToBytes, tenantDidHex, toAgentAuthUpdateWire, toBaseUnits, validateConfig, validateTail, verifyDkgAttestation, verifyTdxQuote };
4032
- export type { AdmitForOrgOptions, AgentAuthEntry, AgentAuthMergeResult, AgentAuthPolicy, AgentAuthScriptGrant, AgentAuthUpdateInput, AuthInput, BalanceRow, ChargeReason, ClientAuth, ClientHandshake, ConfigValidationResult, ContractExecuteInput, ContractKind, ContractPublishInput, ContractRegisterResult, ContractResponseSchema, ContractSetDescriptorInput, CreatePolicyInput, DataGetInput, DataGetResponse, DataListInput, DataListResponse, DelegationGrantKind, DelegationGrantRef, DeleteDataInput, DeleteGrantsInput, DeleteScopeInput, Did, Direction, DkgAttestation, DkgVerifyResult, EmailOtpAuthInput, EmailOtpCredentials, Environment, EthAuthInput, ExecuteBusinessContractOptions, ExecuteOrgDataActionOptions, GetUsageOptions, GrantCheckParams, GrantCheckResult, GrantsGetInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, ListContractsParams, ListContractsResult, ListContractsScope, ListedContract, Logger, MapCreateInput, MapLifecycleStatus, MapResponse, MapUpdateInput, MapVisibility, MutationResponse, OidcAuthInput, OidcCredentials, OrgAdminStatus, OrgContractGrants, OrgDataActionWire, OrgDataClientOptions, OrgPolicyMeta, OrgPolicyView, OrgUsageReport, OrgUsageReportInput, OrgWriters, OtpChannel, OtpMergeSuggestion, OtpRequestInput, OtpRequestResult, OtpVerifyInput, OtpVerifyResult, PayrollRunRequest, PeerQuoteResult, PolicyGetInput, QuoteVerifyResult, ReaderSet, SdkConfig, SessionCrypto, SessionId, SetGrantsInput, SetWritersInput, StringEncoding, SubmitUserInputArgs, SubmitUserInputResult, T3nClientConfig, TenantAdmitProjection, TenantAdmitStatus, TenantBaseClient, TenantClientConfig, TenantContractExecuteInput, TenantContractPublishInput, TenantContractSetDescriptorInput, TenantExecutionSession, TenantMapCreateInput, TenantMapUpdatePatch, TenantMeResponse, TenantSdkEnvironment, TenantSelfAdmitResult, TenantStatus, TenantTargetOptions, TokenTxKind, Transport, TrustAnchor, TrustAnchorOrUnsafe, UnsafeTrustServer, UpdateMetaInput, UsageEntry, UsagePage, UsageReportSignature, UserGrant, UserInputProfile, UserUpsertErrorKind, WasmComponent, WasmNextResult, WireBlock, WorkloadAuthInput, WriteDataInput, WriterSet, WritersGetInput };
4139
+ export { AGENT_CARDS_SCOPE, AuthMethod, AuthenticationError, BASE_UNITS_PER_TOKEN, ContractResponseError, DEFAULT_ENVIRONMENT, DEFAULT_INDIVIDUAL_THRESHOLD_CENTS, DEFAULT_KYC_POLL_CADENCE, HandshakeError, HttpTransport, KycStatusTimeoutError, LogLevel, MockTransport, NODE_URLS, OrgDataClient, OtpRateLimitedError, RpcError, SessionExpiredError, SessionOrgDataClient, SessionStateError, SessionStatus, SessionUsageReportClient, T3nClient, T3nError, TERMINAL_KYC_STATUSES, TOKEN_DECIMALS, TenantClient, TenantContractsNamespace, TenantMapsNamespace, TenantNamespace, TenantSdkValidationError, TenantTokenNamespace, UnsupportedTenantSdkOperationError, UserUpsertError, WasmError, WireEncodingError, Z_PAYROLL_AUDIT_READ_FUNCTIONS, Z_PAYROLL_RUN_FUNCTIONS, _b64uEncode, assertShape, b64uDecodeStrict, b64uEncodeBytes, bytesToString, canonicalTenantName, clearKeyCache, compactDidFromBytes, createDefaultHandlers, createEmailOtpAuthInput, createEthAuthInput, createLogger, createMlKemPublicKeyHandler, createOidcAuthInput, createOrgDataClientFromSession, createRandomHandler, createUsageReportClientFromSession, createWorkloadAuthInput, decodeWasmErrorMessage, deriveAgentCardEntryId, eth_get_address, extractWasmError, fetchDkgAttestation, fetchMlKemPublicKey, formatTokens, generateRandomString, generateUUID, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger, getNodeUrl, getScriptVersion, isAgentCardResponse, isDataGetResponse, isDataListResponse, isMutationResponse, isObject, isOrgAdminStatus, isOrgContractGrants, isOrgPolicyMeta, isOrgPolicyView, isOrgUsageReport, isOrgWriters, isUnsafeTrustServer, loadConfig, loadWasmComponent, maskKeyMaterial, mergeAgentAuthEntries, mergeDiscoverDids, metamask_get_address, metamask_sign, parseAgentAuthGet, parseAgentAuthPolicy, parseContractResponse, redactSecrets, redactSecretsFromJson, requestToWire, setEnvironment, setGlobalLogLevel, setNodeUrl, stringToBytes, tenantDidHex, toAgentAuthUpdateWire, toBaseUnits, validateConfig, validateTail, verifyDkgAttestation, verifyTdxQuote };
4140
+ export type { AdmitForOrgOptions, AgentAuthEntry, AgentAuthMergeResult, AgentAuthPolicy, AgentAuthScriptGrant, AgentAuthUpdateInput, AgentCardRefInput, AgentCardResponse, AgentCardSetInput, AuthInput, BalanceRow, ChargeReason, ClientAuth, ClientHandshake, ConfigValidationResult, ContractExecuteInput, ContractKind, ContractPublishInput, ContractRegisterResult, ContractResponseSchema, ContractSetDescriptorInput, CreatePolicyInput, DataGetInput, DataGetResponse, DataListInput, DataListResponse, DelegationGrantKind, DelegationGrantRef, DeleteDataInput, DeleteGrantsInput, DeleteScopeInput, Did, Direction, DkgAttestation, DkgVerifyResult, EmailOtpAuthInput, EmailOtpCredentials, Environment, EthAuthInput, ExecuteBusinessContractOptions, ExecuteOrgDataActionOptions, GetUsageOptions, GrantCheckParams, GrantCheckResult, GrantsGetInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, ListContractsParams, ListContractsResult, ListContractsScope, ListedContract, Logger, MapCreateInput, MapLifecycleStatus, MapResponse, MapUpdateInput, MapVisibility, MutationResponse, OidcAuthInput, OidcCredentials, OrgAdminStatus, OrgContractGrants, OrgDataActionWire, OrgDataClientOptions, OrgPolicyMeta, OrgPolicyView, OrgUsageReport, OrgUsageReportInput, OrgWriters, OtpChannel, OtpMergeSuggestion, OtpRequestInput, OtpRequestResult, OtpVerifyInput, OtpVerifyResult, PayrollRunRequest, PeerQuoteResult, PolicyGetInput, QuoteVerifyResult, ReaderSet, SdkConfig, SessionCrypto, SessionId, SetGrantsInput, SetWritersInput, StringEncoding, SubmitUserInputArgs, SubmitUserInputResult, T3nClientConfig, TenantAdmitProjection, TenantAdmitStatus, TenantBaseClient, TenantClientConfig, TenantContractExecuteInput, TenantContractPublishInput, TenantContractSetDescriptorInput, TenantExecutionSession, TenantMapCreateInput, TenantMapUpdatePatch, TenantMeResponse, TenantSdkEnvironment, TenantSelfAdmitResult, TenantStatus, TenantTargetOptions, TokenTxKind, Transport, TrustAnchor, TrustAnchorOrUnsafe, UnsafeTrustServer, UpdateMetaInput, UsageEntry, UsagePage, UsageReportSignature, UserGrant, UserInputProfile, UserUpsertErrorKind, WasmComponent, WasmNextResult, WireBlock, WorkloadAuthInput, WriteDataInput, WriterSet, WritersGetInput };