@terminal3/t3n-sdk 4.13.0 → 4.15.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
@@ -1993,6 +1993,57 @@ declare class T3nClient {
1993
1993
  * empty / too long)
1994
1994
  */
1995
1995
  createOrganisation(name: string): Promise<Did>;
1996
+ /**
1997
+ * Provision a fresh org-owned agent.
1998
+ *
1999
+ * Dispatches `create-agent` on `tee:organisation/contracts` over the
2000
+ * standard authenticated `action.execute` path. The node injects the
2001
+ * caller's DID into the contract call context, and the contract refuses
2002
+ * unless the caller is listed as an admin of `organisationDid`. A brand
2003
+ * new secp256k1 wallet is minted in-TEE for the agent; its eth-derived
2004
+ * DID and its raw private key are both returned. The private key is the
2005
+ * "authentication token" the MCP sidecar uses to authenticate as this
2006
+ * agent (the existing `PRIVATE_KEY` eth auth mode) — it is generated and
2007
+ * returned exactly once here and is never persisted or recoverable
2008
+ * afterwards, so the caller must capture it immediately.
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
+ *
2025
+ * @param organisationDid - the owning organisation's DID
2026
+ * (`did:t3n:<40-hex>`); the caller must be one of its admins
2027
+ * @param name - human-readable agent name (1..=128 bytes)
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
2032
+ * @throws if the session is not authenticated, or if the contract
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<{
2042
+ agentDid: Did;
2043
+ privateKey: string;
2044
+ agentUri?: string;
2045
+ cardEntryId?: string;
2046
+ }>;
1996
2047
  /**
1997
2048
  * Read the authenticated user's own agent-auth policy — the standing
1998
2049
  * grants delegated to agents. Dispatches `agent-auth-get` on
@@ -2754,7 +2805,10 @@ declare function isOrgAdminStatus(value: unknown): value is OrgAdminStatus;
2754
2805
  * Mirrors the org-data `MutationResponse` wire shape.
2755
2806
  */
2756
2807
  interface MutationResponse {
2757
- /** `"created"`, `"updated"`, or `"deleted"`. */
2808
+ /**
2809
+ * `"created"`, `"updated"`, `"deleted"`, or — for the agent-card mutations —
2810
+ * `"published"` / `"unpublished"`.
2811
+ */
2758
2812
  status: string;
2759
2813
  /** Hex-encoded entry ID; present on data write/delete operations. */
2760
2814
  entry_id?: string;
@@ -2821,6 +2875,20 @@ interface DataGetResponse {
2821
2875
  }
2822
2876
  /** Shallow runtime guard for {@link DataGetResponse}. */
2823
2877
  declare function isDataGetResponse(value: unknown): value is DataGetResponse;
2878
+ /**
2879
+ * Return shape of `agentCardGet` — composed client-side from the generic
2880
+ * `org-data-get` read of the card's entry (there is no card-specific read
2881
+ * operation on the contract). To check whether a public copy exists, probe
2882
+ * the anonymous `GET /api/agent-card/{did}` endpoint.
2883
+ */
2884
+ interface AgentCardResponse {
2885
+ /** The agent whose card this is (`did:t3n:<40-hex>`). */
2886
+ agent_did: string;
2887
+ /** The stored card JSON body, verbatim. */
2888
+ card: string;
2889
+ }
2890
+ /** Shallow runtime guard for {@link AgentCardResponse}. */
2891
+ declare function isAgentCardResponse(value: unknown): value is AgentCardResponse;
2824
2892
  /**
2825
2893
  * Legacy direct-route org-data envelope shape retained for compatibility.
2826
2894
  *
@@ -2857,6 +2925,21 @@ interface OrgDataActionWire {
2857
2925
  * constructing one-shot signed HTTP envelopes per call.
2858
2926
  */
2859
2927
 
2928
+ /**
2929
+ * Org-data scope agent cards are stored under. The private card body is
2930
+ * ordinary org-data — written / read / deleted with the generic
2931
+ * `org-data-*` operations under this scope; only publication has dedicated
2932
+ * contract operations.
2933
+ */
2934
+ declare const AGENT_CARDS_SCOPE = "agent-cards";
2935
+ /**
2936
+ * Derive the canonical org-data entry ID an agent card is stored under:
2937
+ * the first 16 bytes of `SHA-256(owner ‖ "agent-cards" ‖ agent ‖ u64_be(0))`
2938
+ * — byte-identical to the contract's `derive_entry_id(owner, "agent-cards",
2939
+ * agent, 0)`, so `agent-card-publish` finds the entry without a reverse
2940
+ * lookup. Returned as 32 lowercase hex chars (the wire `entry_id` format).
2941
+ */
2942
+ declare function deriveAgentCardEntryId(ownerDid: string, agentDid: string): string;
2860
2943
  interface CreatePolicyInput {
2861
2944
  orgDid: string;
2862
2945
  initialAdminDid: string;
@@ -2970,6 +3053,27 @@ interface DataGetInput {
2970
3053
  /** Hex-encoded entry ID (32 hex chars). */
2971
3054
  entryId: string;
2972
3055
  }
3056
+ interface AgentCardSetInput {
3057
+ /**
3058
+ * The card owner (`did:t3n:<40-hex>`) — an org DID (written by its
3059
+ * `agent-cards` scope writers) or an individual/agent DID (a self-owned
3060
+ * data space: the owner itself writes, no org needed).
3061
+ */
3062
+ ownerDid: string;
3063
+ /** The agent whose card this is (`did:t3n:<40-hex>`). */
3064
+ agentDid: string;
3065
+ /**
3066
+ * Full card JSON body. Validated locally (non-empty / ≤ 16 KiB / JSON) —
3067
+ * the same gate the contract applies at publish time.
3068
+ */
3069
+ card: string;
3070
+ }
3071
+ /** Reference to a single agent's card by `(owner, agent)`. */
3072
+ interface AgentCardRefInput {
3073
+ /** The card owner — an org DID or an individual/agent DID. */
3074
+ ownerDid: string;
3075
+ agentDid: string;
3076
+ }
2973
3077
  interface ExecuteOrgDataActionOptions {
2974
3078
  /**
2975
3079
  * Deprecated. The direct signed-envelope transport used this as the
@@ -3117,6 +3221,33 @@ declare class OrgDataClient {
3117
3221
  dataList(input: DataListInput): Promise<DataListResponse>;
3118
3222
  /** Retrieve a single data entry by entry ID (admin-only). */
3119
3223
  dataGet(input: DataGetInput): Promise<DataGetResponse>;
3224
+ /**
3225
+ * Create or overwrite an agent's private card (org scope-writer, or the
3226
+ * owner itself for a self-owned space). Validates locally with the same
3227
+ * gate the contract applies at publish. The card stays private until
3228
+ * {@link agentCardPublish}.
3229
+ */
3230
+ agentCardSet(input: AgentCardSetInput): Promise<MutationResponse>;
3231
+ /**
3232
+ * Delete an agent's private card. Does NOT unpublish — publication is
3233
+ * explicit state; call {@link agentCardUnpublish} to retract the public copy.
3234
+ */
3235
+ agentCardDelete(input: AgentCardRefInput): Promise<MutationResponse>;
3236
+ /**
3237
+ * Publish an agent's card to the world-readable `public:agent_cards` map
3238
+ * (served at `GET /api/agent-card/{did}`). The contract validates the
3239
+ * stored bytes, then byte-copies them. Publishing under a third-party
3240
+ * agent DID requires the agent's registry record to name this owner
3241
+ * (consent link); implicit when the owner IS the agent.
3242
+ */
3243
+ agentCardPublish(input: AgentCardRefInput): Promise<MutationResponse>;
3244
+ /** Remove an agent's card from `public:agent_cards`. */
3245
+ agentCardUnpublish(input: AgentCardRefInput): Promise<MutationResponse>;
3246
+ /**
3247
+ * Read an agent's private card (org: admin or delegation-credential holder
3248
+ * for the `agent-cards` scope; self-owned: the owner).
3249
+ */
3250
+ agentCardGet(input: AgentCardRefInput): Promise<AgentCardResponse>;
3120
3251
  }
3121
3252
  /**
3122
3253
  * Session-authenticated variant of {@link OrgDataClient}.
@@ -3189,6 +3320,16 @@ declare class SessionOrgDataClient {
3189
3320
  dataList(input: DataListInput): Promise<DataListResponse>;
3190
3321
  /** Mirrors {@link OrgDataClient.dataGet}. */
3191
3322
  dataGet(input: DataGetInput): Promise<DataGetResponse>;
3323
+ /** Mirrors {@link OrgDataClient.agentCardSet}. */
3324
+ agentCardSet(input: AgentCardSetInput): Promise<MutationResponse>;
3325
+ /** Mirrors {@link OrgDataClient.agentCardDelete}. */
3326
+ agentCardDelete(input: AgentCardRefInput): Promise<MutationResponse>;
3327
+ /** Mirrors {@link OrgDataClient.agentCardPublish}. */
3328
+ agentCardPublish(input: AgentCardRefInput): Promise<MutationResponse>;
3329
+ /** Mirrors {@link OrgDataClient.agentCardUnpublish}. */
3330
+ agentCardUnpublish(input: AgentCardRefInput): Promise<MutationResponse>;
3331
+ /** Mirrors {@link OrgDataClient.agentCardGet}. */
3332
+ agentCardGet(input: AgentCardRefInput): Promise<AgentCardResponse>;
3192
3333
  }
3193
3334
  /**
3194
3335
  * Construct a {@link SessionOrgDataClient} from a caller-owned
@@ -4002,5 +4143,5 @@ declare function tenantDidHex(tenantDid: string): string;
4002
4143
  declare function validateTail(tail: string): string;
4003
4144
  declare function canonicalTenantName(tenantDid: string, tail: string): string;
4004
4145
 
4005
- 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 };
4006
- 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 };
4146
+ 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 };
4147
+ 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 };