@heyanon-arp/sdk 0.0.18 → 0.0.23

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.
@@ -0,0 +1,2 @@
1
+ export { POST_COMMIT_ERROR_CODES, POST_COMMIT_ERROR_CODE_PREFIXES, isPostCommitErrorCode } from './post-commit';
2
+ export type { PostCommitErrorCode } from './post-commit';
@@ -0,0 +1,34 @@
1
+ /**
2
+ * ARP error codes that fire AFTER the server has committed the envelope
3
+ * event row to the hash chain (so the sender_sequence is consumed) but
4
+ * BEFORE the body handler materialises any read-model state.
5
+ *
6
+ * This is a single shared contract with two consumers:
7
+ * - the CLI advances `lastSenderSequence` on these (otherwise the next
8
+ * envelope reuses the consumed sequence and trips ENV_SEQUENCE_BACKWARDS);
9
+ * - the server marks the just-committed event `readModelStatus='rejected'`
10
+ * (otherwise `events --success-only` / the webhook reconciler would
11
+ * treat a rejected action as a materialised one).
12
+ *
13
+ * Previously this list lived in FOUR hand-maintained copies — three CLI
14
+ * sets (delegation/work/receipt) + the server's
15
+ * `PRE_MATERIALIZATION_REJECTION_CODES` — which had already drifted
16
+ * (the server was missing `RECEIPT_INVALID_STATE`). It is now owned here.
17
+ */
18
+ export declare const POST_COMMIT_ERROR_CODES: readonly ["DELEGATION_ALREADY_EXISTS", "DELEGATION_INVALID_STATE", "DELEGATION_NOT_FOUND", "DELEGATION_RELATIONSHIP_MISMATCH", "DELEGATION_ACCEPTER_IS_OFFERER", "DELEGATION_DECLINER_IS_OFFERER", "DELEGATION_CANCELER_NOT_OFFERER", "DELEGATION_ASSET_NOT_ALLOWED", "DELEGATION_PRICING_MISMATCH", "DELEGATION_CAPACITY_EXCEEDED", "DELEGATION_PENDING_LOCK", "DELEGATION_FUNDER_NOT_OFFERER", "DELEGATION_ALREADY_FUNDED", "WORK_DELEGATION_NOT_FOUND", "WORK_DELEGATION_NOT_ACTIVE", "WORK_RELATIONSHIP_MISMATCH", "WORK_REQUESTER_NOT_OFFERER", "WORK_REQUEST_ALREADY_EXISTS", "WORK_REQUEST_NOT_FOUND", "WORK_RESPONDER_IS_CALLER", "WORK_INVALID_STATE", "RECEIPT_ALREADY_EXISTS", "RECEIPT_DELEGATION_NOT_FOUND", "RECEIPT_DELEGATION_NOT_ACTIVE", "RECEIPT_RELATIONSHIP_MISMATCH", "RECEIPT_ISSUER_IS_CALLER", "RECEIPT_NOT_FOUND", "RECEIPT_INVALID_STATE", "RECEIPT_RESPONSE_HASH_NOT_FOUND", "RECEIPT_REQUEST_HASH_NOT_FOUND", "RECEIPT_DELIVERABLE_HASH_MISMATCH"];
19
+ export type PostCommitErrorCode = (typeof POST_COMMIT_ERROR_CODES)[number];
20
+ /**
21
+ * Code-FAMILY prefixes that are always post-commit, enumerated rather
22
+ * than listed member-by-member because they grow over time:
23
+ * - `ESC_LOCK_*` — on-chain lock-validator cross-check rejections fire
24
+ * after the delegation/fund event is committed, before materialisation.
25
+ * - `SDK_*` — SDK-layer throws (canonical-encode / signature / id) that
26
+ * the server's internal-exception filter stamps with an `SDK_` code.
27
+ * These only appear in the FINAL wire code a CLIENT sees, so they
28
+ * matter to the CLI. Server-side classification runs in the message
29
+ * handler BEFORE that code is assigned, so the prefix is simply never
30
+ * matched there — harmless to share the same predicate.
31
+ */
32
+ export declare const POST_COMMIT_ERROR_CODE_PREFIXES: readonly ["ESC_LOCK_", "SDK_"];
33
+ /** True if `code` is a post-commit error code (explicit member OR prefix family). */
34
+ export declare function isPostCommitErrorCode(code: string): boolean;
@@ -4,4 +4,4 @@ export { parseCaip19SolanaAssetId, type ParsedSolanaAssetId } from './caip19';
4
4
  export type { EscrowConfigStatus } from './config-status';
5
5
  export { buildCreateLockIxData, computeCreateLockDiscriminator, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, type CreateLockArgs, } from './create-lock';
6
6
  export { ESCROW_PDA_SEEDS, NO_ARG_LIFECYCLE_INSTRUCTIONS, type NoArgLifecycleInstruction, instructionDiscriminator, buildLifecycleIxData, buildResolveDisputeIxData, type ResolveDisputeArgs, } from './lifecycle-instructions';
7
- export { LOCK_ACCOUNT_SIZE, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, LockStates, ESCROW_RELEASE_METHODS, EscrowReleaseMethods, NATIVE_SOL_MINT_BASE58, type LockStateName, type LockTerminalState, type EscrowReleaseMethodName, isEscrowReleaseMethod, type DecodedLockAccount, decodeLockAccount, computeLockAccountDiscriminator, } from './lock-account';
7
+ export { LOCK_ACCOUNT_SIZE, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, LockStates, LockTerminalStates, ESCROW_RELEASE_METHODS, EscrowReleaseMethods, NATIVE_SOL_MINT_BASE58, type LockStateName, type LockTerminalState, type EscrowReleaseMethodName, isEscrowReleaseMethod, type DecodedLockAccount, decodeLockAccount, computeLockAccountDiscriminator, } from './lock-account';
@@ -16,6 +16,20 @@ export declare const LOCK_TERMINAL_STATES: readonly ["canceled", "paid", "revoke
16
16
  * field both source this type instead of re-listing the literals.
17
17
  */
18
18
  export type LockTerminalState = (typeof LOCK_TERMINAL_STATES)[number];
19
+ /**
20
+ * Named-member accessor for the terminal lock states (the subset that a
21
+ * receipt's `release_status` / a delegation's `releaseStatus` can hold).
22
+ * The server's `ReceiptReleaseStatus` enum and any `releaseStatus`
23
+ * field source these instead of re-listing the literals. Vocab-tested
24
+ * against {@link LOCK_TERMINAL_STATES}.
25
+ */
26
+ export declare const LockTerminalStates: {
27
+ readonly CANCELED: "canceled";
28
+ readonly PAID: "paid";
29
+ readonly REVOKED: "revoked";
30
+ readonly DISPUTE_RESOLVED: "dispute_resolved";
31
+ readonly DISPUTE_CLOSED: "dispute_closed";
32
+ };
19
33
  /**
20
34
  * On-chain `WorkPaymentClaimed.claim_type` → how a paid lock was
21
35
  * released. Discriminant order = u8 value (0 = buyer_approved,
package/dist/index.d.ts CHANGED
@@ -32,3 +32,4 @@ export * from './utils';
32
32
  export * from './types';
33
33
  export * from './assets';
34
34
  export * from './escrow';
35
+ export * from './errors';
package/dist/index.js CHANGED
@@ -813,6 +813,13 @@ var LOCK_ACCOUNT_SIZE = 269;
813
813
  var LOCK_ACCOUNT_DISCRIMINATOR = new Uint8Array([8, 255, 36, 202, 210, 22, 57, 137]);
814
814
  var LOCK_STATE_NAMES = ["created", "canceled", "in_progress", "submitted", "paid", "revoked", "disputing", "dispute_resolved", "dispute_closed"];
815
815
  var LOCK_TERMINAL_STATES = ["canceled", "paid", "revoked", "dispute_resolved", "dispute_closed"];
816
+ var LockTerminalStates = {
817
+ CANCELED: "canceled",
818
+ PAID: "paid",
819
+ REVOKED: "revoked",
820
+ DISPUTE_RESOLVED: "dispute_resolved",
821
+ DISPUTE_CLOSED: "dispute_closed"
822
+ };
816
823
  var ESCROW_RELEASE_METHODS = ["buyer_approved", "review_timeout"];
817
824
  function isEscrowReleaseMethod(v) {
818
825
  return typeof v === "string" && ESCROW_RELEASE_METHODS.includes(v);
@@ -884,6 +891,49 @@ function readU64LE(buf, off) {
884
891
  return v;
885
892
  }
886
893
 
894
+ // src/errors/post-commit.ts
895
+ var POST_COMMIT_ERROR_CODES = [
896
+ // delegation handler (offer / accept / decline / cancel / fund)
897
+ "DELEGATION_ALREADY_EXISTS",
898
+ "DELEGATION_INVALID_STATE",
899
+ "DELEGATION_NOT_FOUND",
900
+ "DELEGATION_RELATIONSHIP_MISMATCH",
901
+ "DELEGATION_ACCEPTER_IS_OFFERER",
902
+ "DELEGATION_DECLINER_IS_OFFERER",
903
+ "DELEGATION_CANCELER_NOT_OFFERER",
904
+ "DELEGATION_ASSET_NOT_ALLOWED",
905
+ "DELEGATION_PRICING_MISMATCH",
906
+ "DELEGATION_CAPACITY_EXCEEDED",
907
+ "DELEGATION_PENDING_LOCK",
908
+ "DELEGATION_FUNDER_NOT_OFFERER",
909
+ "DELEGATION_ALREADY_FUNDED",
910
+ // work handler (request / respond)
911
+ "WORK_DELEGATION_NOT_FOUND",
912
+ "WORK_DELEGATION_NOT_ACTIVE",
913
+ "WORK_RELATIONSHIP_MISMATCH",
914
+ "WORK_REQUESTER_NOT_OFFERER",
915
+ "WORK_REQUEST_ALREADY_EXISTS",
916
+ "WORK_REQUEST_NOT_FOUND",
917
+ "WORK_RESPONDER_IS_CALLER",
918
+ "WORK_INVALID_STATE",
919
+ // receipt handler (propose)
920
+ "RECEIPT_ALREADY_EXISTS",
921
+ "RECEIPT_DELEGATION_NOT_FOUND",
922
+ "RECEIPT_DELEGATION_NOT_ACTIVE",
923
+ "RECEIPT_RELATIONSHIP_MISMATCH",
924
+ "RECEIPT_ISSUER_IS_CALLER",
925
+ "RECEIPT_NOT_FOUND",
926
+ "RECEIPT_INVALID_STATE",
927
+ "RECEIPT_RESPONSE_HASH_NOT_FOUND",
928
+ "RECEIPT_REQUEST_HASH_NOT_FOUND",
929
+ "RECEIPT_DELIVERABLE_HASH_MISMATCH"
930
+ ];
931
+ var POST_COMMIT_ERROR_CODE_PREFIXES = ["ESC_LOCK_", "SDK_"];
932
+ var POST_COMMIT_SET = new Set(POST_COMMIT_ERROR_CODES);
933
+ function isPostCommitErrorCode(code) {
934
+ return POST_COMMIT_SET.has(code) || POST_COMMIT_ERROR_CODE_PREFIXES.some((p) => code.startsWith(p));
935
+ }
936
+
887
937
  exports.ASSET_DECIMALS_MAX = ASSET_DECIMALS_MAX;
888
938
  exports.ASSET_DECIMALS_MIN = ASSET_DECIMALS_MIN;
889
939
  exports.ASSET_SYMBOL_MAX_LEN = ASSET_SYMBOL_MAX_LEN;
@@ -921,12 +971,15 @@ exports.LOCK_ACCOUNT_SIZE = LOCK_ACCOUNT_SIZE;
921
971
  exports.LOCK_STATE_NAMES = LOCK_STATE_NAMES;
922
972
  exports.LOCK_TERMINAL_STATES = LOCK_TERMINAL_STATES;
923
973
  exports.LockStates = LockStates;
974
+ exports.LockTerminalStates = LockTerminalStates;
924
975
  exports.MAINNET_MINTS = MAINNET_MINTS;
925
976
  exports.MAX_CLOCK_SKEW_SECONDS = MAX_CLOCK_SKEW_SECONDS;
926
977
  exports.MAX_ENVELOPE_TTL_SECONDS = MAX_ENVELOPE_TTL_SECONDS;
927
978
  exports.NATIVE_SOL_MINT_BASE58 = NATIVE_SOL_MINT_BASE58;
928
979
  exports.NO_ARG_LIFECYCLE_INSTRUCTIONS = NO_ARG_LIFECYCLE_INSTRUCTIONS;
929
980
  exports.OWNER_SIGNING_METHODS = OWNER_SIGNING_METHODS;
981
+ exports.POST_COMMIT_ERROR_CODES = POST_COMMIT_ERROR_CODES;
982
+ exports.POST_COMMIT_ERROR_CODE_PREFIXES = POST_COMMIT_ERROR_CODE_PREFIXES;
930
983
  exports.PROTOCOL_VERSIONS = PROTOCOL_VERSIONS;
931
984
  exports.Purpose = Purpose;
932
985
  exports.READ_MODEL_STATUSES = READ_MODEL_STATUSES;
@@ -981,6 +1034,7 @@ exports.isDiscoverySort = isDiscoverySort;
981
1034
  exports.isEscrowReleaseMethod = isEscrowReleaseMethod;
982
1035
  exports.isHandshakeDecision = isHandshakeDecision;
983
1036
  exports.isInboxBlockScope = isInboxBlockScope;
1037
+ exports.isPostCommitErrorCode = isPostCommitErrorCode;
984
1038
  exports.isReadModelStatus = isReadModelStatus;
985
1039
  exports.isReceiptVerdict = isReceiptVerdict;
986
1040
  exports.isRelationshipState = isRelationshipState;
package/dist/index.mjs CHANGED
@@ -788,6 +788,13 @@ var LOCK_ACCOUNT_SIZE = 269;
788
788
  var LOCK_ACCOUNT_DISCRIMINATOR = new Uint8Array([8, 255, 36, 202, 210, 22, 57, 137]);
789
789
  var LOCK_STATE_NAMES = ["created", "canceled", "in_progress", "submitted", "paid", "revoked", "disputing", "dispute_resolved", "dispute_closed"];
790
790
  var LOCK_TERMINAL_STATES = ["canceled", "paid", "revoked", "dispute_resolved", "dispute_closed"];
791
+ var LockTerminalStates = {
792
+ CANCELED: "canceled",
793
+ PAID: "paid",
794
+ REVOKED: "revoked",
795
+ DISPUTE_RESOLVED: "dispute_resolved",
796
+ DISPUTE_CLOSED: "dispute_closed"
797
+ };
791
798
  var ESCROW_RELEASE_METHODS = ["buyer_approved", "review_timeout"];
792
799
  function isEscrowReleaseMethod(v) {
793
800
  return typeof v === "string" && ESCROW_RELEASE_METHODS.includes(v);
@@ -859,4 +866,47 @@ function readU64LE(buf, off) {
859
866
  return v;
860
867
  }
861
868
 
862
- export { ASSET_DECIMALS_MAX, ASSET_DECIMALS_MIN, ASSET_SYMBOL_MAX_LEN, ASSET_SYMBOL_MIN_LEN, ASSET_WHITELIST, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, BODY_TYPES, BodyTypes, CAIP19_REGEX, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, CURRENT_PROTOCOL_VERSION, DECIMAL_AMOUNT_REGEX, DECLINE_REASONS, DELEGATION_ACTIONS, DELEGATION_ACTIVE_STATES, DELEGATION_STATES, DEVNET_MINTS, DISCOVERY_SORTS, DelegationActions, DelegationStates, DiscoverySorts, ED25519_SIG_PREFIX, ESCROW_PDA_SEEDS, ESCROW_PROGRAM_ID_BASE58, ESCROW_RELEASE_METHODS, EscrowReleaseMethods, HANDSHAKE_DECISIONS, HandshakeDecisions, INBOX_BLOCK_SCOPES, InboxBlockScopes, LIVE_RELATIONSHIP_STATE_NAMES, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_ACCOUNT_SIZE, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, LockStates, MAINNET_MINTS, MAX_CLOCK_SKEW_SECONDS, MAX_ENVELOPE_TTL_SECONDS, NATIVE_SOL_MINT_BASE58, NO_ARG_LIFECYCLE_INSTRUCTIONS, OWNER_SIGNING_METHODS, PROTOCOL_VERSIONS, Purpose, READ_MODEL_STATUSES, RECEIPT_VERDICTS, RELATIONSHIP_STATE_NAMES, ReadModelStatuses, ReceiptVerdicts, RelationshipStates, SCRYPT_PARAMS, SHA256_HEX_RE, SLIP44_SOLANA, SOLANA_CLUSTER_IDS, SPL_TOKEN_PROGRAM_ID_BASE58, SYSTEM_PROGRAM_ID_BASE58, TOKEN_2022_PROGRAM_ID_BASE58, WELL_KNOWN_ASSETS, WELL_KNOWN_ASSET_KEYS, WORK_LOG_STATES, WorkLogStates, base58btcDecode, base58btcEncode, buildCreateLockIxData, buildLifecycleIxData, buildResolveDisputeIxData, bytes16ToDelegationId, canonicalBytes, canonicalJson, canonicalSha256Hex, computeCreateLockDiscriminator, computeLockAccountDiscriminator, decodeLockAccount, delegationIdToBytes16, deriveDelegationConditionHash, deriveLockId, deriveScryptKey, detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes, expiresAt, findAssetByAssetId, findFirstChainDivergence, formatDid, generateKeyPair, getPublicKey2 as getPublicKey, instructionDiscriminator, isAssetIdentifier, isBodyType, isDecimalAmountString, isDeclineReason, isDelegationAction, isDelegationState, isDiscoverySort, isEscrowReleaseMethod, isHandshakeDecision, isInboxBlockScope, isReadModelStatus, isReceiptVerdict, isRelationshipState, isSha256Hex, isValidDid, isWhitelistedAssetId, isWorkLogState, listWhitelistedAssets, parseCaip19SolanaAssetId, parseDid, pollUntil, resolveAsset, rfc3339, scryptPasswordProofSign, scryptPasswordProofVerify, senderNonce, serverEventHash, sign2 as sign, signChallenge, signEnvelope, signKeyLinkAttestation, signedMessageHash, uuidV4, verify2 as verify, verifyChallenge, verifyEnvelope, verifyKeyLinkAttestation };
869
+ // src/errors/post-commit.ts
870
+ var POST_COMMIT_ERROR_CODES = [
871
+ // delegation handler (offer / accept / decline / cancel / fund)
872
+ "DELEGATION_ALREADY_EXISTS",
873
+ "DELEGATION_INVALID_STATE",
874
+ "DELEGATION_NOT_FOUND",
875
+ "DELEGATION_RELATIONSHIP_MISMATCH",
876
+ "DELEGATION_ACCEPTER_IS_OFFERER",
877
+ "DELEGATION_DECLINER_IS_OFFERER",
878
+ "DELEGATION_CANCELER_NOT_OFFERER",
879
+ "DELEGATION_ASSET_NOT_ALLOWED",
880
+ "DELEGATION_PRICING_MISMATCH",
881
+ "DELEGATION_CAPACITY_EXCEEDED",
882
+ "DELEGATION_PENDING_LOCK",
883
+ "DELEGATION_FUNDER_NOT_OFFERER",
884
+ "DELEGATION_ALREADY_FUNDED",
885
+ // work handler (request / respond)
886
+ "WORK_DELEGATION_NOT_FOUND",
887
+ "WORK_DELEGATION_NOT_ACTIVE",
888
+ "WORK_RELATIONSHIP_MISMATCH",
889
+ "WORK_REQUESTER_NOT_OFFERER",
890
+ "WORK_REQUEST_ALREADY_EXISTS",
891
+ "WORK_REQUEST_NOT_FOUND",
892
+ "WORK_RESPONDER_IS_CALLER",
893
+ "WORK_INVALID_STATE",
894
+ // receipt handler (propose)
895
+ "RECEIPT_ALREADY_EXISTS",
896
+ "RECEIPT_DELEGATION_NOT_FOUND",
897
+ "RECEIPT_DELEGATION_NOT_ACTIVE",
898
+ "RECEIPT_RELATIONSHIP_MISMATCH",
899
+ "RECEIPT_ISSUER_IS_CALLER",
900
+ "RECEIPT_NOT_FOUND",
901
+ "RECEIPT_INVALID_STATE",
902
+ "RECEIPT_RESPONSE_HASH_NOT_FOUND",
903
+ "RECEIPT_REQUEST_HASH_NOT_FOUND",
904
+ "RECEIPT_DELIVERABLE_HASH_MISMATCH"
905
+ ];
906
+ var POST_COMMIT_ERROR_CODE_PREFIXES = ["ESC_LOCK_", "SDK_"];
907
+ var POST_COMMIT_SET = new Set(POST_COMMIT_ERROR_CODES);
908
+ function isPostCommitErrorCode(code) {
909
+ return POST_COMMIT_SET.has(code) || POST_COMMIT_ERROR_CODE_PREFIXES.some((p) => code.startsWith(p));
910
+ }
911
+
912
+ export { ASSET_DECIMALS_MAX, ASSET_DECIMALS_MIN, ASSET_SYMBOL_MAX_LEN, ASSET_SYMBOL_MIN_LEN, ASSET_WHITELIST, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, BODY_TYPES, BodyTypes, CAIP19_REGEX, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, CURRENT_PROTOCOL_VERSION, DECIMAL_AMOUNT_REGEX, DECLINE_REASONS, DELEGATION_ACTIONS, DELEGATION_ACTIVE_STATES, DELEGATION_STATES, DEVNET_MINTS, DISCOVERY_SORTS, DelegationActions, DelegationStates, DiscoverySorts, ED25519_SIG_PREFIX, ESCROW_PDA_SEEDS, ESCROW_PROGRAM_ID_BASE58, ESCROW_RELEASE_METHODS, EscrowReleaseMethods, HANDSHAKE_DECISIONS, HandshakeDecisions, INBOX_BLOCK_SCOPES, InboxBlockScopes, LIVE_RELATIONSHIP_STATE_NAMES, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_ACCOUNT_SIZE, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, LockStates, LockTerminalStates, MAINNET_MINTS, MAX_CLOCK_SKEW_SECONDS, MAX_ENVELOPE_TTL_SECONDS, NATIVE_SOL_MINT_BASE58, NO_ARG_LIFECYCLE_INSTRUCTIONS, OWNER_SIGNING_METHODS, POST_COMMIT_ERROR_CODES, POST_COMMIT_ERROR_CODE_PREFIXES, PROTOCOL_VERSIONS, Purpose, READ_MODEL_STATUSES, RECEIPT_VERDICTS, RELATIONSHIP_STATE_NAMES, ReadModelStatuses, ReceiptVerdicts, RelationshipStates, SCRYPT_PARAMS, SHA256_HEX_RE, SLIP44_SOLANA, SOLANA_CLUSTER_IDS, SPL_TOKEN_PROGRAM_ID_BASE58, SYSTEM_PROGRAM_ID_BASE58, TOKEN_2022_PROGRAM_ID_BASE58, WELL_KNOWN_ASSETS, WELL_KNOWN_ASSET_KEYS, WORK_LOG_STATES, WorkLogStates, base58btcDecode, base58btcEncode, buildCreateLockIxData, buildLifecycleIxData, buildResolveDisputeIxData, bytes16ToDelegationId, canonicalBytes, canonicalJson, canonicalSha256Hex, computeCreateLockDiscriminator, computeLockAccountDiscriminator, decodeLockAccount, delegationIdToBytes16, deriveDelegationConditionHash, deriveLockId, deriveScryptKey, detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes, expiresAt, findAssetByAssetId, findFirstChainDivergence, formatDid, generateKeyPair, getPublicKey2 as getPublicKey, instructionDiscriminator, isAssetIdentifier, isBodyType, isDecimalAmountString, isDeclineReason, isDelegationAction, isDelegationState, isDiscoverySort, isEscrowReleaseMethod, isHandshakeDecision, isInboxBlockScope, isPostCommitErrorCode, isReadModelStatus, isReceiptVerdict, isRelationshipState, isSha256Hex, isValidDid, isWhitelistedAssetId, isWorkLogState, listWhitelistedAssets, parseCaip19SolanaAssetId, parseDid, pollUntil, resolveAsset, rfc3339, scryptPasswordProofSign, scryptPasswordProofVerify, senderNonce, serverEventHash, sign2 as sign, signChallenge, signEnvelope, signKeyLinkAttestation, signedMessageHash, uuidV4, verify2 as verify, verifyChallenge, verifyEnvelope, verifyKeyLinkAttestation };
@@ -1,3 +1,4 @@
1
+ import type { DidDocument } from '../did/document';
1
2
  /**
2
3
  * Agent accept-preferences ("PricingPolicy") — the worker-side "what I
3
4
  * accept" constraints a registered agent publishes on its profile.
@@ -56,3 +57,82 @@ export interface AcceptCurrency {
56
57
  */
57
58
  maxAmount?: string;
58
59
  }
60
+ /**
61
+ * Response from agent registration (`POST /v1/agents`; the server DTO
62
+ * is `AgentRegisteredDto`). The {@link DidDocument} shape is the SDK's
63
+ * canonical one from `../did/document`.
64
+ */
65
+ export interface AgentRegisteredResponse {
66
+ did: string;
67
+ didDocument: DidDocument;
68
+ }
69
+ /**
70
+ * Public view of an ARP agent — signed reads (`GET /v1/agents/:did`)
71
+ * and the profile `PATCH` response. Owner-only material (raw scrypt,
72
+ * encrypted secrets) never appears here.
73
+ */
74
+ export interface AgentPublic {
75
+ did: string;
76
+ /** Identity public key, base58btc. Immutable — the DID derives from it. */
77
+ identityPublicKey: string;
78
+ /** Settlement (Solana) public key, base58btc. */
79
+ settlementPublicKey: string;
80
+ /** attestationId of the live KEY-LINK row. */
81
+ currentAttestationId: string;
82
+ name?: string;
83
+ description?: string;
84
+ /** Capability tags — always present (empty array when none). */
85
+ tags: string[];
86
+ /** Accept-preferences — absent ⇒ the agent accepts anything. */
87
+ acceptPrefs?: AcceptPrefs;
88
+ registeredAt: string;
89
+ createdAt: string;
90
+ updatedAt: string;
91
+ }
92
+ /**
93
+ * Partial profile-update body for `PATCH /v1/agents/:did`. Omitted
94
+ * fields stay as-is; `tags` present REPLACES the whole list (send `[]`
95
+ * to clear); `acceptPrefs` present REPLACES the object (`null` clears).
96
+ */
97
+ export interface UpdateAgentBody {
98
+ name?: string;
99
+ description?: string;
100
+ tags?: string[];
101
+ acceptPrefs?: AcceptPrefs | null;
102
+ }
103
+ /** 0..100 reputation score vector (neutral 50 cold-start). */
104
+ export interface ReputationScores {
105
+ reliability: number;
106
+ settlement: number;
107
+ disputeHealth: number;
108
+ composite: number;
109
+ }
110
+ /** Raw evidence counters behind the reputation scores. */
111
+ export interface ReputationCounters {
112
+ onchainCycles: number;
113
+ completedDelegations: number;
114
+ completedAsPayer: number;
115
+ completedAsPayee: number;
116
+ failedDelegations: number;
117
+ settledEscrows: number;
118
+ refundedEscrows: number;
119
+ disputedEscrows: number;
120
+ disputesAdverse: number;
121
+ distinctCounterparts: number;
122
+ activeRelationships: number;
123
+ }
124
+ /**
125
+ * Public reputation view — `GET /v1/agents/:did/reputation`.
126
+ * INFORMATIONAL ONLY (a display + soft-sort signal, never a money /
127
+ * eligibility gate; `informational` is always true in alpha). Scores
128
+ * are 0..100 with a neutral 50 cold-start; `computed: false` ⇒ the
129
+ * agent has never settled a cycle and the neutral vector is shown.
130
+ */
131
+ export interface AgentReputation {
132
+ did: string;
133
+ informational: boolean;
134
+ scores: ReputationScores;
135
+ counters: ReputationCounters;
136
+ computed: boolean;
137
+ lastComputedAt?: string | null;
138
+ }
@@ -1,3 +1,4 @@
1
+ import type { AcceptPrefs, AgentReputation } from './agent';
1
2
  /**
2
3
  * Discovery catalog sort order for `GET /v1/discovery/agents`. Single
3
4
  * source of truth for the server's `@IsIn`/`@ApiProperty` allowlist and
@@ -16,3 +17,71 @@ export declare const DiscoverySorts: {
16
17
  readonly RECENT: "recent";
17
18
  readonly CREATED: "created";
18
19
  };
20
+ /** Reputation digest carried inline on each discovery row (the soft-sort key). */
21
+ export interface DiscoveryReputation {
22
+ composite: number;
23
+ reliability: number;
24
+ settlement: number;
25
+ disputeHealth: number;
26
+ computed: boolean;
27
+ }
28
+ /** Liveness digest — how recently / whether the agent is reachable. */
29
+ export interface DiscoveryLiveness {
30
+ /** Durable: a signed request within the liveness window (replica-accurate). */
31
+ online: boolean;
32
+ /** Live: an open SSE inbox stream on the serving instance (per-process). */
33
+ inboxStreamActive: boolean;
34
+ /** RFC 3339 of the last signed request; null ⇒ never seen since registration. */
35
+ lastSeenAt?: string | null;
36
+ }
37
+ /**
38
+ * One discovery search row — a privacy-safe subset of the agent
39
+ * profile (NO accountId / key material) enriched with the reputation
40
+ * soft-sort key + liveness.
41
+ */
42
+ export interface DiscoveryResult {
43
+ id: string;
44
+ did: string;
45
+ name?: string;
46
+ description?: string;
47
+ tags: string[];
48
+ acceptPrefs?: AcceptPrefs;
49
+ reputation: DiscoveryReputation;
50
+ liveness: DiscoveryLiveness;
51
+ registeredAt: string;
52
+ }
53
+ /** Pagination envelope metadata on a discovery search page. */
54
+ export interface DiscoveryPagination {
55
+ /** Count of ALL agents matching the filters (ignores the page window). */
56
+ total: number;
57
+ limit: number;
58
+ /** ceil(total / limit). */
59
+ totalPages: number;
60
+ hasMore: boolean;
61
+ /** Zero-based page index — offset sorts (reputation / recent) only. */
62
+ page?: number;
63
+ /** Cursor for the next page — `sort=created` only, when hasMore (pass as `after`). */
64
+ nextCursor?: string | null;
65
+ }
66
+ /** `GET /v1/discovery/search` response — a page of rows + pagination metadata. */
67
+ export interface DiscoverySearchResponse {
68
+ results: DiscoveryResult[];
69
+ pagination: DiscoveryPagination;
70
+ }
71
+ /**
72
+ * `GET /v1/discovery/agents/:did/profile` — the composed single-agent
73
+ * view: public profile + full reputation + liveness in one read.
74
+ */
75
+ export interface DiscoveryProfile {
76
+ did: string;
77
+ name?: string;
78
+ description?: string;
79
+ tags: string[];
80
+ acceptPrefs?: AcceptPrefs;
81
+ registeredAt: string;
82
+ reputation: AgentReputation;
83
+ /** Liveness, plus `lastEventAt` (last protocol event either side). */
84
+ liveness: DiscoveryLiveness & {
85
+ lastEventAt?: string | null;
86
+ };
87
+ }
@@ -15,3 +15,19 @@ export declare const InboxBlockScopes: {
15
15
  readonly ACCOUNT: "account";
16
16
  readonly DID: "did";
17
17
  };
18
+ /**
19
+ * One row of the owner's inbox block list (`/v1/inbox/blocks`).
20
+ * Privacy-safe: it echoes back only the DID you NAMED + scope — never
21
+ * the resolved owner `accountId` and never the swept sibling DIDs. For
22
+ * `account` scope you learn "I blocked the owner of this DID", not who
23
+ * else that owner runs.
24
+ */
25
+ export interface InboxBlock {
26
+ scope: InboxBlockScope;
27
+ /** The DID you named when blocking. */
28
+ did: string;
29
+ /** Your private note, or null. */
30
+ reason: string | null;
31
+ /** When the block was set (ISO 8601). */
32
+ blockedAt: string;
33
+ }
@@ -10,11 +10,12 @@ export type { WorkLogState } from './work-log';
10
10
  export { WORK_LOG_STATES, WorkLogStates, isWorkLogState } from './work-log';
11
11
  export type { ReadModelStatus } from './event';
12
12
  export { READ_MODEL_STATUSES, ReadModelStatuses, isReadModelStatus } from './event';
13
- export type { DiscoverySort } from './discovery';
13
+ export type { DiscoverySort, DiscoveryReputation, DiscoveryLiveness, DiscoveryResult, DiscoveryPagination, DiscoverySearchResponse, DiscoveryProfile, } from './discovery';
14
14
  export { DISCOVERY_SORTS, DiscoverySorts, isDiscoverySort } from './discovery';
15
- export type { InboxBlockScope } from './inbox';
15
+ export type { InboxBlockScope, InboxBlock } from './inbox';
16
16
  export { INBOX_BLOCK_SCOPES, InboxBlockScopes, isInboxBlockScope } from './inbox';
17
17
  export type { CliSessionCreated, CliTokenIssued, CliWhoami, MyAgentSummary } from './cli-auth';
18
- export type { AcceptPrefs, AcceptCurrency } from './agent';
18
+ export type { AssetIdentifierWire, DelegationPublic, ReceiptPublic, RelationshipPublic, WorkLogPublic, EventPublic, IngestResult } from './read-model';
19
+ export type { AcceptPrefs, AcceptCurrency, AgentRegisteredResponse, AgentPublic, UpdateAgentBody, ReputationScores, ReputationCounters, AgentReputation, } from './agent';
19
20
  export type { OwnerSigningMethod, KeyLinkPayload, ScryptPasswordAttestation } from './identity';
20
21
  export { SCRYPT_PARAMS, OWNER_SIGNING_METHODS } from './identity';
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Public read-model row shapes returned by the server's relationship
3
+ * read endpoints and consumed by the CLI. Framework-agnostic plain
4
+ * interfaces (no decorators): the server's NestJS DTO classes
5
+ * `implements` these (keeping their @ApiProperty/@nestjs decorators for
6
+ * OpenAPI) and the CLI imports them directly — so the wire contract
7
+ * lives in ONE place and can't drift between the two packages.
8
+ */
9
+ import type { LockTerminalState } from '../escrow/lock-account';
10
+ import type { BodyType, ReceiptVerdict } from './body';
11
+ import type { DelegationState } from './delegation';
12
+ import type { ReadModelStatus } from './event';
13
+ import type { RelationshipState } from './relationship';
14
+ import type { WorkLogState } from './work-log';
15
+ /**
16
+ * camelCase REST projection of an asset identifier (the snake_case
17
+ * envelope form is {@link AssetIdentifier} in body.ts). Embedded on
18
+ * `DelegationPublic.currency`.
19
+ */
20
+ export interface AssetIdentifierWire {
21
+ /** CAIP-19 chain-qualified asset id. */
22
+ assetId: string;
23
+ /** Decimals 0-18, for amount → base-unit conversion. */
24
+ decimals: number;
25
+ /** Optional UI hint ("USDC", "SOL"). */
26
+ symbol?: string;
27
+ }
28
+ /**
29
+ * Public projection of one delegation row (one per delegationId).
30
+ * `id` is the per-row Mongo ObjectId hex — the opaque `?after=` cursor.
31
+ */
32
+ export interface DelegationPublic {
33
+ id: string;
34
+ delegationId: string;
35
+ relationshipId: string;
36
+ offererDid: string;
37
+ state: DelegationState;
38
+ title?: string;
39
+ brief?: Record<string, unknown>;
40
+ acceptanceCriteria?: string[];
41
+ deadline?: string;
42
+ amount?: string;
43
+ currency?: AssetIdentifierWire;
44
+ /** Inline agreed terms the on-chain condition_hash binds. */
45
+ scopeSummary?: string;
46
+ createdAt: string;
47
+ updatedAt: string;
48
+ /** Machine-readable decline reason — present only on DECLINED rows. */
49
+ declineReason?: string | null;
50
+ declineReasonDetail?: string | null;
51
+ /** On-chain settlement outcome, set by the indexer at the terminal flip. */
52
+ releaseStatus?: LockTerminalState;
53
+ }
54
+ /**
55
+ * Public projection of one receipt row (one per
56
+ * delegationId/requestHash/responseHash). Receipts are propose-only.
57
+ */
58
+ export interface ReceiptPublic {
59
+ id: string;
60
+ delegationId: string;
61
+ relationshipId: string;
62
+ payeeDid: string;
63
+ callerDid: string;
64
+ requestHash: string;
65
+ /** Opaque request_id from the matching work_request, denormalised at propose. */
66
+ requestId?: string;
67
+ responseHash: string;
68
+ verdictProposed: ReceiptVerdict;
69
+ usage?: {
70
+ input_tokens?: number;
71
+ output_tokens?: number;
72
+ latency_ms?: number;
73
+ model?: string;
74
+ computed_amount?: string;
75
+ };
76
+ deliverableHash?: string;
77
+ notesHash?: string;
78
+ receiptEventHash: string;
79
+ /** On-chain settlement outcome, stamped by the indexer on terminal. */
80
+ releaseStatus?: LockTerminalState;
81
+ createdAt: string;
82
+ updatedAt: string;
83
+ }
84
+ /** Public projection of one relationship row (per DID pair). */
85
+ export interface RelationshipPublic {
86
+ relationshipId: string;
87
+ pairDidA: string;
88
+ pairDidB: string;
89
+ state: RelationshipState;
90
+ lastEventIndex: number;
91
+ lastServerEventHash: string | null;
92
+ lastEventAt: string | null;
93
+ createdAt: string;
94
+ updatedAt: string;
95
+ /** Handshake decline reason — present on CLOSED rows from a decline. */
96
+ declineReason?: string | null;
97
+ declineReasonDetail?: string | null;
98
+ }
99
+ /**
100
+ * Public projection of one work-log row (per delegationId/requestId).
101
+ * Two-step FSM: a RESPONDED row carries exactly one of responseOutput /
102
+ * responseError.
103
+ */
104
+ export interface WorkLogPublic {
105
+ id: string;
106
+ delegationId: string;
107
+ requestId: string;
108
+ relationshipId: string;
109
+ callerDid: string;
110
+ payeeDid: string;
111
+ state: WorkLogState;
112
+ requestParams: Record<string, unknown>;
113
+ responseOutput?: Record<string, unknown>;
114
+ responseError?: {
115
+ code: string;
116
+ message: string;
117
+ };
118
+ createdAt: string;
119
+ updatedAt: string;
120
+ }
121
+ /**
122
+ * Public projection of one event row — the FULL canonical envelope
123
+ * (protectedBlock + body + optional attachments + senderSignature) plus
124
+ * the server-assigned chain coordinates, so a recipient can
125
+ * re-canonicalise + re-verify locally. `type` is widened to
126
+ * `BodyType | string` for forward-compat (a server may emit a body type
127
+ * a given client's union doesn't yet know).
128
+ */
129
+ export interface EventPublic {
130
+ eventId: string;
131
+ messageId: string;
132
+ senderDid: string;
133
+ recipientDid: string;
134
+ relationshipId: string;
135
+ senderSequence: number;
136
+ protocolVersion: string;
137
+ purpose: string;
138
+ type: BodyType | string;
139
+ protectedBlock: Record<string, unknown>;
140
+ body: Record<string, unknown>;
141
+ attachments?: Record<string, unknown>;
142
+ senderSignature: string;
143
+ relationshipEventIndex: number;
144
+ prevServerEventHash: string | null;
145
+ serverTimestamp: string;
146
+ signedMessageHash: string;
147
+ serverEventHash: string;
148
+ /** Read-model outcome; `rejected` = committed to chain but body handler threw post-commit. */
149
+ readModelStatus: ReadModelStatus;
150
+ }
151
+ /** Response shape for `POST /v1/messages` (202 accepted, chain already committed). */
152
+ export interface IngestResult {
153
+ eventId: string;
154
+ relationshipEventIndex: number;
155
+ prevServerEventHash: string | null;
156
+ signedMessageHash: string;
157
+ serverEventHash: string;
158
+ serverTimestamp: string;
159
+ relationshipId: string;
160
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyanon-arp/sdk",
3
- "version": "0.0.18",
3
+ "version": "0.0.23",
4
4
  "description": "TypeScript SDK for the Agent Relationship Protocol — canonical JSON, Ed25519 envelope sign/verify, did:arp identity, scrypt key attestation, chain-audit helpers.",
5
5
  "license": "MIT",
6
6
  "keywords": [