@terminal3/t3n-sdk 4.24.0 → 4.26.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
@@ -1615,6 +1615,112 @@ interface GetAuditEventsOptions {
1615
1615
  cursor?: string;
1616
1616
  }
1617
1617
 
1618
+ /**
1619
+ * Agent-activity audit-log wire shapes (the node's `auditlog` RPC).
1620
+ *
1621
+ * Mirrors `service::activity_audit::{ActivityReport, ReportEntry}` and
1622
+ * `primitives::audit_log::AuditLogEntry`. One entry per audited contract
1623
+ * dispatch — who called, for whom, which contract + function, and how it
1624
+ * ended. Entries are reconstructed from the append-only ledger on read, so
1625
+ * `seq_no` (the ledger index) and `hash` are derived server-side rather than
1626
+ * stored with the record.
1627
+ *
1628
+ * Scope is the caller's **own organisation**, resolved node-side from the
1629
+ * session DID: there is no scope parameter, and a page carries **every
1630
+ * member's** activity in that org, not just the caller's own. Metadata only —
1631
+ * DIDs, never display names, call arguments, or payloads.
1632
+ */
1633
+ /**
1634
+ * Whether the actor is a registered agent or a human / self principal.
1635
+ * Decided node-side by an existence check on the actor DID in the agent
1636
+ * registry — never inferred from the DID's shape.
1637
+ */
1638
+ type ActivityCallerType = "agent" | "human";
1639
+ /**
1640
+ * Host-stamped outcome of an audited dispatch.
1641
+ *
1642
+ * - `success` — the business transaction committed.
1643
+ * - `denied` — authorisation refused the call.
1644
+ * - `error` — the call was allowed but failed / rolled back.
1645
+ */
1646
+ type ActivityOutcome = "success" | "denied" | "error";
1647
+ /** One audited call. */
1648
+ interface ActivityEntry {
1649
+ /**
1650
+ * Ledger index of the entry — its unique, ordered id. Use it as the row key
1651
+ * and as the ordering key: it is monotonic, whereas {@link timestamp_ms} is
1652
+ * per-node wall clock.
1653
+ */
1654
+ seq_no: number;
1655
+ /** Hex SHA-256 of the stored entry (64 chars) — read-time tamper evidence. */
1656
+ hash: string;
1657
+ /**
1658
+ * Call time in Unix ms, stamped on the node that took the request. NOT a
1659
+ * cluster-assigned time, so entries from different nodes can be skewed by
1660
+ * their clock offset — order by {@link seq_no}, not by this.
1661
+ */
1662
+ timestamp_ms: number;
1663
+ /** Agent vs human, from the agent-registry check on {@link actor}. */
1664
+ caller_type: ActivityCallerType;
1665
+ /** DID that actually invoked the contract. */
1666
+ actor: string;
1667
+ /**
1668
+ * DID of the owner the caller acted for. Equals {@link actor} on a self /
1669
+ * own-authority call — never null.
1670
+ */
1671
+ on_behalf_of: string;
1672
+ /**
1673
+ * Organisation the acting principal belongs to — the report's scope key, so
1674
+ * it is identical on every row of a page. Falls back to `on_behalf_of` when
1675
+ * that principal is in no organisation.
1676
+ */
1677
+ org: string;
1678
+ /** Contract that ran, e.g. `tee:user/contracts`. */
1679
+ contract: string;
1680
+ /** Contract function invoked, e.g. `user-upsert`. */
1681
+ function: string;
1682
+ /** success / denied / error — host-stamped from the dispatch result. */
1683
+ outcome: ActivityOutcome;
1684
+ }
1685
+ /**
1686
+ * One page of the organisation's activity report — **newest first**, i.e.
1687
+ * descending `seq_no`.
1688
+ */
1689
+ interface ActivityReport {
1690
+ entries: ActivityEntry[];
1691
+ /**
1692
+ * Cursor to resume from — pass it back as
1693
+ * {@link GetActivityLogOptions.before_seq}. `null` once the requested window
1694
+ * is exhausted.
1695
+ *
1696
+ * A live cursor with **fewer rows than `limit`, or none at all**, is normal:
1697
+ * the node also caps how much ledger one call decrypts, and that cap can trip
1698
+ * before the window ends. Page until this is `null`, never on a short or
1699
+ * empty page.
1700
+ */
1701
+ next_seq: number | null;
1702
+ }
1703
+ /** Params for one activity-report page. All optional; `{}` is valid. */
1704
+ interface GetActivityLogOptions {
1705
+ /** Window start, Unix ms, inclusive. Defaults to 0 (no lower bound). */
1706
+ from_ms?: number;
1707
+ /** Window end, Unix ms, inclusive. Defaults to unbounded. */
1708
+ to_ms?: number;
1709
+ /**
1710
+ * Cursor, inclusive — the highest `seq_no` this page may return. Omitted ⇒
1711
+ * start at the newest entry in the window. Pages walk downwards, so this is
1712
+ * the previous page's {@link ActivityReport.next_seq}.
1713
+ */
1714
+ before_seq?: number;
1715
+ /**
1716
+ * Rows returned this page. Clamped server-side to 1–1000 (default 200).
1717
+ *
1718
+ * A page can still be shorter than this (or empty) with a live `next_seq` —
1719
+ * the node's own scan cap can trip first. See {@link ActivityReport.next_seq}.
1720
+ */
1721
+ limit?: number;
1722
+ }
1723
+
1618
1724
  /**
1619
1725
  * Contract-discovery wire shapes.
1620
1726
  *
@@ -1947,6 +2053,39 @@ declare class T3nClient {
1947
2053
  * caller DID is bound from the session, never the body.
1948
2054
  */
1949
2055
  getAuditEvents(opts?: GetAuditEventsOptions): Promise<AuditPage>;
2056
+ /**
2057
+ * Fetch one page of the caller's **organisation's** agent-activity audit log
2058
+ * (`auditlog`): every audited contract dispatch — actor, on-behalf-of,
2059
+ * contract, function, outcome — reconstructed from the append-only ledger.
2060
+ *
2061
+ * The scope organisation is resolved node-side from the session DID, so
2062
+ * there is no scope parameter and a caller can only ever read their own org.
2063
+ * The page carries **every member's** activity in that org, not just the
2064
+ * caller's own.
2065
+ *
2066
+ * Like {@link getAuditEvents} / {@link getUsage}, this runs the session
2067
+ * payload encryption: entries carry principal DIDs, so params and response
2068
+ * are sealed to the session key rather than sent plaintext over TLS.
2069
+ *
2070
+ * Rows come back **newest first**. Page by handing the previous page's
2071
+ * `next_seq` back as `before_seq`, and stop when it comes back `null` —
2072
+ * **not** on a short or empty page: the node also caps how much ledger a
2073
+ * single call decrypts, so a page can be shorter than `limit` while the window
2074
+ * still has rows.
2075
+ *
2076
+ * ```ts
2077
+ * let cursor: number | undefined;
2078
+ * do {
2079
+ * const page = await client.getActivityLog({
2080
+ * limit: 200,
2081
+ * ...(cursor !== undefined && { before_seq: cursor }),
2082
+ * });
2083
+ * render(page.entries);
2084
+ * cursor = page.next_seq ?? undefined;
2085
+ * } while (cursor !== undefined);
2086
+ * ```
2087
+ */
2088
+ getActivityLog(opts?: GetActivityLogOptions): Promise<ActivityReport>;
1950
2089
  /**
1951
2090
  * Execute an action with an attached binary blob using multipart RPC.
1952
2091
  */
@@ -4665,4 +4804,4 @@ declare function validateTail(tail: string): string;
4665
4804
  declare function canonicalTenantName(tenantDid: string, tail: string): string;
4666
4805
 
4667
4806
  export { AGENT_CARDS_SCOPE, AuthMethod, AuthenticationError, BASE_UNITS_PER_TOKEN, ContractResponseError, DEFAULT_ENVIRONMENT, DEFAULT_INDIVIDUAL_THRESHOLD_CENTS, DEFAULT_KYC_POLL_CADENCE, HandshakeError, HttpTransport, InvokeError, 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, clearManifestVersionFloor, compactDidFromBytes, createDefaultHandlers, createEmailOtpAuthInput, createEthAuthInput, createLogger, createMlKemPublicKeyHandler, createOidcAuthInput, createOrgDataClientFromSession, createRandomHandler, createUsageReportClientFromSession, createWorkloadAuthInput, decodeWasmErrorMessage, deriveAgentCardEntryId, eth_get_address, extractWasmError, fetchDkgAttestation, fetchMlKemPublicKey, fetchTrustedManifest, formatTokens, generateRandomString, generateUUID, getEnvironment, getEnvironmentName, getGlobalLogLevel, getLogger, getNodeUrl, getScriptVersion, invoke, isAgentCardResponse, isDataGetResponse, isDataListResponse, isListAgentsResponse, isMutationResponse, isObject, isOrgAdminStatus, isOrgContractGrants, isOrgPolicyMeta, isOrgPolicyView, isOrgUsageReport, isOrgWriters, isRoleAssignmentsResponse, isRoleGetResponse, isUnsafeTrustServer, loadConfig, loadWasmComponent, manifestToTrustAnchor, maskKeyMaterial, mergeAgentAuthEntries, mergeDiscoverDids, metamask_get_address, metamask_sign, parseAgentAuthGet, parseAgentAuthPolicy, parseContractResponse, redactSecrets, redactSecretsFromJson, requestToWire, setEnvironment, setGlobalLogLevel, setNodeUrl, stringToBytes, tenantDidHex, toAgentAuthUpdateWire, toBaseUnits, validateConfig, validateTail, verifyDkgAttestation, verifyManifestSignature, verifyTdxQuote };
4668
- export type { AdmitForOrgOptions, AgentAuthEntry, AgentAuthMergeResult, AgentAuthPolicy, AgentAuthScriptGrant, AgentAuthUpdateInput, AgentCardRefInput, AgentCardResponse, AgentCardSetInput, AgentSummary, AssignRolesInput, 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, FetchTrustedManifestOptions, GetUsageOptions, GrantCheckParams, GrantCheckResult, GranteeInput, GrantsGetInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, InvokeOptions, InvokeRequest, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, ListAgentsInput, ListAgentsResponse, 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, PurgeOrgInput, QuoteVerifyResult, ReaderSet, RemoveMemberGrantsInput, RoleAssignments, RoleAssignmentsResponse, RoleDefinition, RoleGetResponse, RoleGrant, RoleIdInput, SdkConfig, SessionCrypto, SessionId, SetGrantsInput, SetRoleInput, SetWritersInput, SignedTrustManifest, StringEncoding, SubmitUserInputArgs, SubmitUserInputResult, T3nClientConfig, TenantAdmitProjection, TenantAdmitStatus, TenantBaseClient, TenantClientConfig, TenantContractExecuteInput, TenantContractPublishInput, TenantContractSetDescriptorInput, TenantExecutionSession, TenantMapCreateInput, TenantMapUpdatePatch, TenantMeResponse, TenantSdkEnvironment, TenantSelfAdmitResult, TenantStatus, TenantTargetOptions, TokenTxKind, Transport, TrustAnchor, TrustAnchorOrUnsafe, TrustManifestPayload, UnassignRolesInput, UnsafeTrustServer, UpdateMetaInput, UsageEntry, UsagePage, UsageReportSignature, UserGrant, UserInputProfile, UserUpsertErrorKind, WasmComponent, WasmNextResult, WireBlock, WorkloadAuthInput, WriteDataInput, WriterSet, WritersGetInput };
4807
+ export type { ActivityCallerType, ActivityEntry, ActivityOutcome, ActivityReport, AdmitForOrgOptions, AgentAuthEntry, AgentAuthMergeResult, AgentAuthPolicy, AgentAuthScriptGrant, AgentAuthUpdateInput, AgentCardRefInput, AgentCardResponse, AgentCardSetInput, AgentSummary, AssignRolesInput, 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, FetchTrustedManifestOptions, GetActivityLogOptions, GetUsageOptions, GrantCheckParams, GrantCheckResult, GranteeInput, GrantsGetInput, GuestToHostHandler, GuestToHostHandlers, HandshakeResult, InvokeOptions, InvokeRequest, JsonRpcRequest, JsonRpcResponse, KycPollCadence, KycPollOptions, KycStatus, KycStatusKind, ListAgentsInput, ListAgentsResponse, 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, PurgeOrgInput, QuoteVerifyResult, ReaderSet, RemoveMemberGrantsInput, RoleAssignments, RoleAssignmentsResponse, RoleDefinition, RoleGetResponse, RoleGrant, RoleIdInput, SdkConfig, SessionCrypto, SessionId, SetGrantsInput, SetRoleInput, SetWritersInput, SignedTrustManifest, StringEncoding, SubmitUserInputArgs, SubmitUserInputResult, T3nClientConfig, TenantAdmitProjection, TenantAdmitStatus, TenantBaseClient, TenantClientConfig, TenantContractExecuteInput, TenantContractPublishInput, TenantContractSetDescriptorInput, TenantExecutionSession, TenantMapCreateInput, TenantMapUpdatePatch, TenantMeResponse, TenantSdkEnvironment, TenantSelfAdmitResult, TenantStatus, TenantTargetOptions, TokenTxKind, Transport, TrustAnchor, TrustAnchorOrUnsafe, TrustManifestPayload, UnassignRolesInput, UnsafeTrustServer, UpdateMetaInput, UsageEntry, UsagePage, UsageReportSignature, UserGrant, UserInputProfile, UserUpsertErrorKind, WasmComponent, WasmNextResult, WireBlock, WorkloadAuthInput, WriteDataInput, WriterSet, WritersGetInput };