@heyanon-arp/sdk 0.0.15 → 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.
package/dist/index.mjs CHANGED
@@ -287,6 +287,7 @@ var SPL_TOKEN_PROGRAM_ID_BASE58 = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
287
287
  var TOKEN_2022_PROGRAM_ID_BASE58 = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
288
288
  var ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
289
289
  var SYSTEM_PROGRAM_ID_BASE58 = "11111111111111111111111111111111";
290
+ var ESCROW_PROGRAM_ID_BASE58 = "DckBAFZcE1AZWgVsz5ipnwSUy2wWeK5eBPBoyJgKVPzb";
290
291
 
291
292
  // src/settlement/token-program.ts
292
293
  function detectTokenProgramFromOwner(mintAccountOwnerBase58) {
@@ -402,6 +403,7 @@ function isSha256Hex(v) {
402
403
  }
403
404
  var ED25519_SIG_PREFIX = "ed25519:";
404
405
  var PROTOCOL_VERSIONS = ["arp/0.1"];
406
+ var CURRENT_PROTOCOL_VERSION = PROTOCOL_VERSIONS[PROTOCOL_VERSIONS.length - 1];
405
407
 
406
408
  // src/types/body.ts
407
409
  var DECLINE_REASONS = ["missing_brief", "rate_too_low", "out_of_scope", "policy", "expired_proposal", "capacity", "unspecified", "other"];
@@ -412,18 +414,43 @@ var HANDSHAKE_DECISIONS = ["accept", "decline"];
412
414
  function isHandshakeDecision(v) {
413
415
  return typeof v === "string" && HANDSHAKE_DECISIONS.includes(v);
414
416
  }
417
+ var HandshakeDecisions = {
418
+ ACCEPT: "accept",
419
+ DECLINE: "decline"
420
+ };
415
421
  var DELEGATION_ACTIONS = ["offer", "accept", "decline", "cancel", "fund"];
416
422
  function isDelegationAction(v) {
417
423
  return typeof v === "string" && DELEGATION_ACTIONS.includes(v);
418
424
  }
425
+ var DelegationActions = {
426
+ OFFER: "offer",
427
+ ACCEPT: "accept",
428
+ DECLINE: "decline",
429
+ CANCEL: "cancel",
430
+ FUND: "fund"
431
+ };
419
432
  var RECEIPT_VERDICTS = ["accepted", "accepted_with_notes", "rejected"];
420
433
  function isReceiptVerdict(v) {
421
434
  return typeof v === "string" && RECEIPT_VERDICTS.includes(v);
422
435
  }
436
+ var ReceiptVerdicts = {
437
+ ACCEPTED: "accepted",
438
+ ACCEPTED_WITH_NOTES: "accepted_with_notes",
439
+ REJECTED: "rejected"
440
+ };
423
441
  var BODY_TYPES = ["handshake", "handshake_response", "delegation", "work_request", "work_response", "receipt", "dispute"];
424
442
  function isBodyType(v) {
425
443
  return typeof v === "string" && BODY_TYPES.includes(v);
426
444
  }
445
+ var BodyTypes = {
446
+ HANDSHAKE: "handshake",
447
+ HANDSHAKE_RESPONSE: "handshake_response",
448
+ DELEGATION: "delegation",
449
+ WORK_REQUEST: "work_request",
450
+ WORK_RESPONSE: "work_response",
451
+ RECEIPT: "receipt",
452
+ DISPUTE: "dispute"
453
+ };
427
454
 
428
455
  // src/types/delegation.ts
429
456
  var DELEGATION_STATES = [
@@ -443,6 +470,19 @@ var DELEGATION_ACTIVE_STATES = ["offered", "accepted", "pending_lock_finalizatio
443
470
  function isDelegationState(v) {
444
471
  return typeof v === "string" && DELEGATION_STATES.includes(v);
445
472
  }
473
+ var DelegationStates = {
474
+ OFFERED: "offered",
475
+ ACCEPTED: "accepted",
476
+ PENDING_LOCK_FINALIZATION: "pending_lock_finalization",
477
+ LOCKED: "locked",
478
+ DISPUTING: "disputing",
479
+ COMPLETED: "completed",
480
+ DECLINED: "declined",
481
+ CANCELED: "canceled",
482
+ FAILED: "failed",
483
+ REFUNDED: "refunded",
484
+ DISPUTE_RESOLVED: "dispute_resolved"
485
+ };
446
486
 
447
487
  // src/types/relationship.ts
448
488
  var RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused", "closed"];
@@ -450,12 +490,53 @@ var LIVE_RELATIONSHIP_STATE_NAMES = ["pending", "active", "paused"];
450
490
  function isRelationshipState(v) {
451
491
  return typeof v === "string" && RELATIONSHIP_STATE_NAMES.includes(v);
452
492
  }
493
+ var RelationshipStates = {
494
+ PENDING: "pending",
495
+ ACTIVE: "active",
496
+ PAUSED: "paused",
497
+ CLOSED: "closed"
498
+ };
453
499
 
454
500
  // src/types/work-log.ts
455
501
  var WORK_LOG_STATES = ["requested", "responded"];
456
502
  function isWorkLogState(v) {
457
503
  return typeof v === "string" && WORK_LOG_STATES.includes(v);
458
504
  }
505
+ var WorkLogStates = {
506
+ REQUESTED: "requested",
507
+ RESPONDED: "responded"
508
+ };
509
+
510
+ // src/types/event.ts
511
+ var READ_MODEL_STATUSES = ["materialized", "rejected"];
512
+ function isReadModelStatus(v) {
513
+ return typeof v === "string" && READ_MODEL_STATUSES.includes(v);
514
+ }
515
+ var ReadModelStatuses = {
516
+ MATERIALIZED: "materialized",
517
+ REJECTED: "rejected"
518
+ };
519
+
520
+ // src/types/discovery.ts
521
+ var DISCOVERY_SORTS = ["reputation", "recent", "created"];
522
+ function isDiscoverySort(v) {
523
+ return typeof v === "string" && DISCOVERY_SORTS.includes(v);
524
+ }
525
+ var DiscoverySorts = {
526
+ REPUTATION: "reputation",
527
+ RECENT: "recent",
528
+ CREATED: "created"
529
+ };
530
+
531
+ // src/types/inbox.ts
532
+ var INBOX_BLOCK_SCOPES = ["account", "did"];
533
+ function isInboxBlockScope(v) {
534
+ return typeof v === "string" && INBOX_BLOCK_SCOPES.includes(v);
535
+ }
536
+ var InboxBlockScopes = {
537
+ ACCOUNT: "account",
538
+ DID: "did"
539
+ };
459
540
 
460
541
  // src/assets.ts
461
542
  var SOLANA_CLUSTER_IDS = {
@@ -527,12 +608,20 @@ function isWhitelistedAssetId(assetId, cluster) {
527
608
  return cluster === void 0 || hit.cluster === cluster;
528
609
  }
529
610
  var CAIP19_REGEX = /^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}$/;
611
+ var ASSET_DECIMALS_MIN = 0;
612
+ var ASSET_DECIMALS_MAX = 18;
613
+ var ASSET_SYMBOL_MIN_LEN = 1;
614
+ var ASSET_SYMBOL_MAX_LEN = 16;
615
+ var DECIMAL_AMOUNT_REGEX = /^\d{1,30}(\.\d{1,18})?$/;
616
+ function isDecimalAmountString(v) {
617
+ return typeof v === "string" && DECIMAL_AMOUNT_REGEX.test(v);
618
+ }
530
619
  function isAssetIdentifier(value) {
531
620
  if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
532
621
  const v = value;
533
622
  if (typeof v.asset_id !== "string" || !CAIP19_REGEX.test(v.asset_id)) return false;
534
- if (typeof v.decimals !== "number" || !Number.isInteger(v.decimals) || v.decimals < 0 || v.decimals > 18) return false;
535
- if (v.symbol !== void 0 && (typeof v.symbol !== "string" || v.symbol.length === 0 || v.symbol.length > 16)) return false;
623
+ if (typeof v.decimals !== "number" || !Number.isInteger(v.decimals) || v.decimals < ASSET_DECIMALS_MIN || v.decimals > ASSET_DECIMALS_MAX) return false;
624
+ if (v.symbol !== void 0 && (typeof v.symbol !== "string" || v.symbol.length < ASSET_SYMBOL_MIN_LEN || v.symbol.length > ASSET_SYMBOL_MAX_LEN)) return false;
536
625
  return true;
537
626
  }
538
627
  function resolveAsset(input) {
@@ -699,6 +788,32 @@ var LOCK_ACCOUNT_SIZE = 269;
699
788
  var LOCK_ACCOUNT_DISCRIMINATOR = new Uint8Array([8, 255, 36, 202, 210, 22, 57, 137]);
700
789
  var LOCK_STATE_NAMES = ["created", "canceled", "in_progress", "submitted", "paid", "revoked", "disputing", "dispute_resolved", "dispute_closed"];
701
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
+ };
798
+ var ESCROW_RELEASE_METHODS = ["buyer_approved", "review_timeout"];
799
+ function isEscrowReleaseMethod(v) {
800
+ return typeof v === "string" && ESCROW_RELEASE_METHODS.includes(v);
801
+ }
802
+ var LockStates = {
803
+ CREATED: "created",
804
+ CANCELED: "canceled",
805
+ IN_PROGRESS: "in_progress",
806
+ SUBMITTED: "submitted",
807
+ PAID: "paid",
808
+ REVOKED: "revoked",
809
+ DISPUTING: "disputing",
810
+ DISPUTE_RESOLVED: "dispute_resolved",
811
+ DISPUTE_CLOSED: "dispute_closed"
812
+ };
813
+ var EscrowReleaseMethods = {
814
+ BUYER_APPROVED: "buyer_approved",
815
+ REVIEW_TIMEOUT: "review_timeout"
816
+ };
702
817
  var NATIVE_SOL_MINT_BASE58 = "11111111111111111111111111111111";
703
818
  function decodeLockAccount(data) {
704
819
  if (data.length !== LOCK_ACCOUNT_SIZE) {
@@ -751,4 +866,47 @@ function readU64LE(buf, off) {
751
866
  return v;
752
867
  }
753
868
 
754
- export { ASSET_WHITELIST, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, BODY_TYPES, CAIP19_REGEX, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, DECLINE_REASONS, DELEGATION_ACTIONS, DELEGATION_ACTIVE_STATES, DELEGATION_STATES, DEVNET_MINTS, ED25519_SIG_PREFIX, ESCROW_PDA_SEEDS, HANDSHAKE_DECISIONS, LIVE_RELATIONSHIP_STATE_NAMES, LOCK_ACCOUNT_DISCRIMINATOR, LOCK_ACCOUNT_SIZE, LOCK_STATE_NAMES, LOCK_TERMINAL_STATES, MAINNET_MINTS, MAX_CLOCK_SKEW_SECONDS, MAX_ENVELOPE_TTL_SECONDS, NATIVE_SOL_MINT_BASE58, NO_ARG_LIFECYCLE_INSTRUCTIONS, OWNER_SIGNING_METHODS, PROTOCOL_VERSIONS, Purpose, RECEIPT_VERDICTS, RELATIONSHIP_STATE_NAMES, 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, 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, isDeclineReason, isDelegationAction, isDelegationState, isHandshakeDecision, 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,3 @@
1
- export { SPL_TOKEN_PROGRAM_ID_BASE58, TOKEN_2022_PROGRAM_ID_BASE58, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, SYSTEM_PROGRAM_ID_BASE58 } from './program-ids';
1
+ export { SPL_TOKEN_PROGRAM_ID_BASE58, TOKEN_2022_PROGRAM_ID_BASE58, ASSOCIATED_TOKEN_PROGRAM_ID_BASE58, SYSTEM_PROGRAM_ID_BASE58, ESCROW_PROGRAM_ID_BASE58 } from './program-ids';
2
2
  export { detectTokenProgramFromOwner, detectTokenProgramFromOwnerBytes } from './token-program';
3
3
  export type { TokenProgramKind, TokenProgramDetection } from './token-program';
@@ -25,3 +25,15 @@ export declare const ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = "ATokenGPvbdGVxr1b2hvZ
25
25
  * escrow module), not this constant: same string, different semantics.
26
26
  */
27
27
  export declare const SYSTEM_PROGRAM_ID_BASE58 = "11111111111111111111111111111111";
28
+ /**
29
+ * ARP escrow program id (current V2 devnet deployment). This is the
30
+ * canonical DEFAULT only — both the CLI and server resolve the program
31
+ * id at runtime (flag / env / config / server probe) and that
32
+ * precedence chain stays authoritative; this constant is the single
33
+ * source for the fallback default so the two packages can't ship
34
+ * DIFFERENT defaults (the CLI previously hardcoded the contract's
35
+ * `declare_id` placeholder while the server defaulted to the deployed
36
+ * id). When a mainnet deployment exists, promote this to a per-cluster
37
+ * map keyed by `SOLANA_CLUSTER_IDS`.
38
+ */
39
+ export declare const ESCROW_PROGRAM_ID_BASE58 = "DckBAFZcE1AZWgVsz5ipnwSUy2wWeK5eBPBoyJgKVPzb";
@@ -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
+ }
@@ -81,6 +81,11 @@ export declare function isDeclineReason(v: unknown): v is DeclineReason;
81
81
  export type HandshakeDecision = 'accept' | 'decline';
82
82
  export declare const HANDSHAKE_DECISIONS: readonly HandshakeDecision[];
83
83
  export declare function isHandshakeDecision(v: unknown): v is HandshakeDecision;
84
+ /** Named-member accessor for {@link HandshakeDecision} (values are the wire strings; vocab-tested). */
85
+ export declare const HandshakeDecisions: {
86
+ readonly ACCEPT: "accept";
87
+ readonly DECLINE: "decline";
88
+ };
84
89
  /**
85
90
  * Lifecycle action on a `delegation` body. `offer` opens the
86
91
  * delegation; `accept`/`decline` are the counterparty's response;
@@ -90,6 +95,14 @@ export declare function isHandshakeDecision(v: unknown): v is HandshakeDecision;
90
95
  export type DelegationAction = 'offer' | 'accept' | 'decline' | 'cancel' | 'fund';
91
96
  export declare const DELEGATION_ACTIONS: readonly DelegationAction[];
92
97
  export declare function isDelegationAction(v: unknown): v is DelegationAction;
98
+ /** Named-member accessor for {@link DelegationAction} (e.g. `action === DelegationActions.CANCEL`; vocab-tested). */
99
+ export declare const DelegationActions: {
100
+ readonly OFFER: "offer";
101
+ readonly ACCEPT: "accept";
102
+ readonly DECLINE: "decline";
103
+ readonly CANCEL: "cancel";
104
+ readonly FUND: "fund";
105
+ };
93
106
  /**
94
107
  * Payee's proposed verdict on a `receipt` body. The record is
95
108
  * off-chain; settlement happens on-chain via `claim_work_payment`.
@@ -97,6 +110,12 @@ export declare function isDelegationAction(v: unknown): v is DelegationAction;
97
110
  export type ReceiptVerdict = 'accepted' | 'accepted_with_notes' | 'rejected';
98
111
  export declare const RECEIPT_VERDICTS: readonly ReceiptVerdict[];
99
112
  export declare function isReceiptVerdict(v: unknown): v is ReceiptVerdict;
113
+ /** Named-member accessor for {@link ReceiptVerdict} (values are the wire strings; vocab-tested). */
114
+ export declare const ReceiptVerdicts: {
115
+ readonly ACCEPTED: "accepted";
116
+ readonly ACCEPTED_WITH_NOTES: "accepted_with_notes";
117
+ readonly REJECTED: "rejected";
118
+ };
100
119
  /**
101
120
  * `handshake` — first signed exchange between two agents. Establishes
102
121
  * the relationship; carries no terms (those live on the delegation).
@@ -243,3 +262,13 @@ export type AnyBody = HandshakeBody | HandshakeResponseBody | DelegationBody | W
243
262
  export type BodyType = AnyBody['type'];
244
263
  export declare const BODY_TYPES: readonly BodyType[];
245
264
  export declare function isBodyType(v: unknown): v is BodyType;
265
+ /** Named-member accessor for {@link BodyType} (values are the wire strings; vocab-tested). */
266
+ export declare const BodyTypes: {
267
+ readonly HANDSHAKE: "handshake";
268
+ readonly HANDSHAKE_RESPONSE: "handshake_response";
269
+ readonly DELEGATION: "delegation";
270
+ readonly WORK_REQUEST: "work_request";
271
+ readonly WORK_RESPONSE: "work_response";
272
+ readonly RECEIPT: "receipt";
273
+ readonly DISPUTE: "dispute";
274
+ };
@@ -0,0 +1,41 @@
1
+ /**
2
+ * `heyarp login` (cli-auth) wire response shapes. Single source of
3
+ * truth for the server's cli-auth-flow service return types and the
4
+ * CLI's response types — both are plain framework-agnostic interfaces
5
+ * (the server declares them in a service, not a NestJS DTO class), so
6
+ * this is a pure lift-and-share with no decorator coupling.
7
+ *
8
+ * NOT included here: the cli-auth SESSION-STATE union
9
+ * ('pending'|'confirmed'|'consumed'|...) — the CLI and server disagree
10
+ * on the terminal members, so it needs reconciliation before it can be
11
+ * centralized.
12
+ */
13
+ /** `POST /v1/auth/cli/sessions` → a new login session. */
14
+ export interface CliSessionCreated {
15
+ sessionId: string;
16
+ verificationUrl: string;
17
+ }
18
+ /** One-time token exchange result (PKCE-style clientSecret-gated). */
19
+ export interface CliTokenIssued {
20
+ token: string;
21
+ wallet: string;
22
+ }
23
+ /** `GET /v1/accounts/me` → who the bearer token authenticates as. */
24
+ export interface CliWhoami {
25
+ wallet: string;
26
+ agentCount: number;
27
+ }
28
+ /**
29
+ * One agent owned by the presented account — the shape `GET
30
+ * /v1/accounts/me/agents` returns. Carries enough to drive recovery
31
+ * (DID + attestation id the CLI rebuilds local state with) plus profile
32
+ * for display. The owner `accountId` itself is NEVER included.
33
+ */
34
+ export interface MyAgentSummary {
35
+ did: string;
36
+ name: string | null;
37
+ description: string | null;
38
+ tags: string[];
39
+ currentAttestationId: string;
40
+ registeredAt: string;
41
+ }
@@ -20,3 +20,24 @@ export type DelegationState = (typeof DELEGATION_STATES)[number];
20
20
  */
21
21
  export declare const DELEGATION_ACTIVE_STATES: readonly ["offered", "accepted", "pending_lock_finalization", "locked"];
22
22
  export declare function isDelegationState(v: unknown): v is DelegationState;
23
+ /**
24
+ * Named-member accessor for the delegation FSM — lets consumers write
25
+ * `state === DelegationStates.LOCKED` / `case DelegationStates.OFFERED:`
26
+ * instead of bare magic strings, while the values stay the exact wire
27
+ * strings (so they remain assignable to {@link DelegationState} with no
28
+ * casts, unlike a TS string-enum). Parity with {@link DELEGATION_STATES}
29
+ * is pinned by the vocab test.
30
+ */
31
+ export declare const DelegationStates: {
32
+ readonly OFFERED: "offered";
33
+ readonly ACCEPTED: "accepted";
34
+ readonly PENDING_LOCK_FINALIZATION: "pending_lock_finalization";
35
+ readonly LOCKED: "locked";
36
+ readonly DISPUTING: "disputing";
37
+ readonly COMPLETED: "completed";
38
+ readonly DECLINED: "declined";
39
+ readonly CANCELED: "canceled";
40
+ readonly FAILED: "failed";
41
+ readonly REFUNDED: "refunded";
42
+ readonly DISPUTE_RESOLVED: "dispute_resolved";
43
+ };
@@ -0,0 +1,87 @@
1
+ import type { AcceptPrefs, AgentReputation } from './agent';
2
+ /**
3
+ * Discovery catalog sort order for `GET /v1/discovery/agents`. Single
4
+ * source of truth for the server's `@IsIn`/`@ApiProperty` allowlist and
5
+ * the CLI's `--sort` union. Same `as const` array + union + guard +
6
+ * named-member const-object shape as the protocol vocabularies.
7
+ *
8
+ * `reputation` = composite score desc (default); `recent` = newest
9
+ * first; `created` = registration order.
10
+ */
11
+ export declare const DISCOVERY_SORTS: readonly ["reputation", "recent", "created"];
12
+ export type DiscoverySort = (typeof DISCOVERY_SORTS)[number];
13
+ export declare function isDiscoverySort(v: unknown): v is DiscoverySort;
14
+ /** Named-member accessor for {@link DiscoverySort} (vocab-tested). */
15
+ export declare const DiscoverySorts: {
16
+ readonly REPUTATION: "reputation";
17
+ readonly RECENT: "recent";
18
+ readonly CREATED: "created";
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
+ }
@@ -33,6 +33,13 @@ export type Did = `did:arp:${string}`;
33
33
  */
34
34
  export declare const PROTOCOL_VERSIONS: readonly ["arp/0.1"];
35
35
  export type ProtocolVersion = (typeof PROTOCOL_VERSIONS)[number];
36
+ /**
37
+ * The wire version this SDK emits. Always the newest entry in
38
+ * {@link PROTOCOL_VERSIONS}. CLI envelope builders sign this instead of
39
+ * the bare `'arp/0.1'` literal, so a version bump is the one-line array
40
+ * change above.
41
+ */
42
+ export declare const CURRENT_PROTOCOL_VERSION: ProtocolVersion;
36
43
  /**
37
44
  * Client-signed `protected` block. All fields here are part of the
38
45
  * signing input. Server-assigned chain fields (`relationship_event_index`,
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Read-model projection outcome for a relationship event: `materialized`
3
+ * (the event was applied to the read model) → `rejected` (the event was
4
+ * recorded on the hash chain but the projector declined to apply it,
5
+ * e.g. an integrity mismatch). Single source of truth for the server's
6
+ * Mongoose `@Prop({ enum })` + the two event-query DTOs and the CLI's
7
+ * `EventPublic.readModelStatus` union / `--read-model-status` filter.
8
+ */
9
+ export declare const READ_MODEL_STATUSES: readonly ["materialized", "rejected"];
10
+ export type ReadModelStatus = (typeof READ_MODEL_STATUSES)[number];
11
+ export declare function isReadModelStatus(v: unknown): v is ReadModelStatus;
12
+ /**
13
+ * Named-member accessor for the read-model projection outcome (see
14
+ * {@link READ_MODEL_STATUSES}). Values are the wire strings; parity is
15
+ * vocab-tested.
16
+ */
17
+ export declare const ReadModelStatuses: {
18
+ readonly MATERIALIZED: "materialized";
19
+ readonly REJECTED: "rejected";
20
+ };
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Inbox-block scope — whether a block targets a whole ACCOUNT (all the
3
+ * blocked party's agents) or a single DID. Single source of truth for
4
+ * the server's Mongoose `@Prop({ enum })` value list and the CLI's
5
+ * `scope` union. Same `as const` array + union + guard + named-member
6
+ * const-object shape as the protocol vocabularies; the server keeps a
7
+ * local enum for member access and sources its @Prop allowlist from
8
+ * `INBOX_BLOCK_SCOPES` with a parity spec.
9
+ */
10
+ export declare const INBOX_BLOCK_SCOPES: readonly ["account", "did"];
11
+ export type InboxBlockScope = (typeof INBOX_BLOCK_SCOPES)[number];
12
+ export declare function isInboxBlockScope(v: unknown): v is InboxBlockScope;
13
+ /** Named-member accessor for {@link InboxBlockScope} (vocab-tested). */
14
+ export declare const InboxBlockScopes: {
15
+ readonly ACCOUNT: "account";
16
+ readonly DID: "did";
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
+ }
@@ -1,13 +1,21 @@
1
1
  export type { Sha256Hex, Ed25519Sig, Did, ProtocolVersion, ProtectedBlock, Body, Attachments, EscrowLockAttachment, Envelope, PersistedEvent, } from './envelope';
2
- export { SHA256_HEX_RE, isSha256Hex, ED25519_SIG_PREFIX, PROTOCOL_VERSIONS } from './envelope';
2
+ export { SHA256_HEX_RE, isSha256Hex, ED25519_SIG_PREFIX, PROTOCOL_VERSIONS, CURRENT_PROTOCOL_VERSION } from './envelope';
3
3
  export type { HandshakeBody, HandshakeContent, HandshakeResponseBody, HandshakeResponseContent, HandshakeDecision, DelegationBody, DelegationContent, DelegationAction, WorkRequestBody, WorkRequestContent, WorkResponseBody, WorkResponseContent, ReceiptBody, ReceiptContent, ReceiptVerdict, DisputeBody, DisputeContent, AnyBody, BodyType, DeclineReason, AssetIdentifier, } from './body';
4
- export { DECLINE_REASONS, isDeclineReason, HANDSHAKE_DECISIONS, isHandshakeDecision, DELEGATION_ACTIONS, isDelegationAction, RECEIPT_VERDICTS, isReceiptVerdict, BODY_TYPES, isBodyType, } from './body';
4
+ export { DECLINE_REASONS, isDeclineReason, HANDSHAKE_DECISIONS, HandshakeDecisions, isHandshakeDecision, DELEGATION_ACTIONS, DelegationActions, isDelegationAction, RECEIPT_VERDICTS, ReceiptVerdicts, isReceiptVerdict, BODY_TYPES, BodyTypes, isBodyType, } from './body';
5
5
  export type { DelegationState } from './delegation';
6
- export { DELEGATION_STATES, DELEGATION_ACTIVE_STATES, isDelegationState } from './delegation';
6
+ export { DELEGATION_STATES, DELEGATION_ACTIVE_STATES, DelegationStates, isDelegationState } from './delegation';
7
7
  export type { RelationshipState } from './relationship';
8
- export { RELATIONSHIP_STATE_NAMES, LIVE_RELATIONSHIP_STATE_NAMES, isRelationshipState } from './relationship';
8
+ export { RELATIONSHIP_STATE_NAMES, LIVE_RELATIONSHIP_STATE_NAMES, RelationshipStates, isRelationshipState } from './relationship';
9
9
  export type { WorkLogState } from './work-log';
10
- export { WORK_LOG_STATES, isWorkLogState } from './work-log';
11
- export type { AcceptPrefs, AcceptCurrency } from './agent';
10
+ export { WORK_LOG_STATES, WorkLogStates, isWorkLogState } from './work-log';
11
+ export type { ReadModelStatus } from './event';
12
+ export { READ_MODEL_STATUSES, ReadModelStatuses, isReadModelStatus } from './event';
13
+ export type { DiscoverySort, DiscoveryReputation, DiscoveryLiveness, DiscoveryResult, DiscoveryPagination, DiscoverySearchResponse, DiscoveryProfile, } from './discovery';
14
+ export { DISCOVERY_SORTS, DiscoverySorts, isDiscoverySort } from './discovery';
15
+ export type { InboxBlockScope, InboxBlock } from './inbox';
16
+ export { INBOX_BLOCK_SCOPES, InboxBlockScopes, isInboxBlockScope } from './inbox';
17
+ export type { CliSessionCreated, CliTokenIssued, CliWhoami, MyAgentSummary } from './cli-auth';
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';
12
20
  export type { OwnerSigningMethod, KeyLinkPayload, ScryptPasswordAttestation } from './identity';
13
21
  export { SCRYPT_PARAMS, OWNER_SIGNING_METHODS } from './identity';