@heyanon-arp/sdk 0.0.18 → 0.0.24
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/errors/index.d.ts +2 -0
- package/dist/errors/post-commit.d.ts +34 -0
- package/dist/escrow/index.d.ts +1 -1
- package/dist/escrow/lock-account.d.ts +14 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +71 -0
- package/dist/index.mjs +64 -1
- package/dist/types/agent.d.ts +103 -0
- package/dist/types/cli-auth.d.ts +28 -4
- package/dist/types/discovery.d.ts +93 -0
- package/dist/types/inbox.d.ts +29 -0
- package/dist/types/index.d.ts +6 -4
- package/dist/types/read-model.d.ts +160 -0
- package/package.json +1 -1
|
@@ -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;
|
package/dist/escrow/index.d.ts
CHANGED
|
@@ -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
package/dist/index.js
CHANGED
|
@@ -563,6 +563,19 @@ var InboxBlockScopes = {
|
|
|
563
563
|
DID: "did"
|
|
564
564
|
};
|
|
565
565
|
|
|
566
|
+
// src/types/cli-auth.ts
|
|
567
|
+
var CLI_LOGIN_SESSION_STORED_STATES = ["pending", "confirmed", "consumed"];
|
|
568
|
+
var CLI_LOGIN_SESSION_STATES = ["pending", "confirmed", "consumed", "expired"];
|
|
569
|
+
function isCliLoginSessionWireState(v) {
|
|
570
|
+
return typeof v === "string" && CLI_LOGIN_SESSION_STATES.includes(v);
|
|
571
|
+
}
|
|
572
|
+
var CliLoginSessionStates = {
|
|
573
|
+
PENDING: "pending",
|
|
574
|
+
CONFIRMED: "confirmed",
|
|
575
|
+
CONSUMED: "consumed",
|
|
576
|
+
EXPIRED: "expired"
|
|
577
|
+
};
|
|
578
|
+
|
|
566
579
|
// src/assets.ts
|
|
567
580
|
var SOLANA_CLUSTER_IDS = {
|
|
568
581
|
"solana-mainnet": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
@@ -813,6 +826,13 @@ var LOCK_ACCOUNT_SIZE = 269;
|
|
|
813
826
|
var LOCK_ACCOUNT_DISCRIMINATOR = new Uint8Array([8, 255, 36, 202, 210, 22, 57, 137]);
|
|
814
827
|
var LOCK_STATE_NAMES = ["created", "canceled", "in_progress", "submitted", "paid", "revoked", "disputing", "dispute_resolved", "dispute_closed"];
|
|
815
828
|
var LOCK_TERMINAL_STATES = ["canceled", "paid", "revoked", "dispute_resolved", "dispute_closed"];
|
|
829
|
+
var LockTerminalStates = {
|
|
830
|
+
CANCELED: "canceled",
|
|
831
|
+
PAID: "paid",
|
|
832
|
+
REVOKED: "revoked",
|
|
833
|
+
DISPUTE_RESOLVED: "dispute_resolved",
|
|
834
|
+
DISPUTE_CLOSED: "dispute_closed"
|
|
835
|
+
};
|
|
816
836
|
var ESCROW_RELEASE_METHODS = ["buyer_approved", "review_timeout"];
|
|
817
837
|
function isEscrowReleaseMethod(v) {
|
|
818
838
|
return typeof v === "string" && ESCROW_RELEASE_METHODS.includes(v);
|
|
@@ -884,6 +904,49 @@ function readU64LE(buf, off) {
|
|
|
884
904
|
return v;
|
|
885
905
|
}
|
|
886
906
|
|
|
907
|
+
// src/errors/post-commit.ts
|
|
908
|
+
var POST_COMMIT_ERROR_CODES = [
|
|
909
|
+
// delegation handler (offer / accept / decline / cancel / fund)
|
|
910
|
+
"DELEGATION_ALREADY_EXISTS",
|
|
911
|
+
"DELEGATION_INVALID_STATE",
|
|
912
|
+
"DELEGATION_NOT_FOUND",
|
|
913
|
+
"DELEGATION_RELATIONSHIP_MISMATCH",
|
|
914
|
+
"DELEGATION_ACCEPTER_IS_OFFERER",
|
|
915
|
+
"DELEGATION_DECLINER_IS_OFFERER",
|
|
916
|
+
"DELEGATION_CANCELER_NOT_OFFERER",
|
|
917
|
+
"DELEGATION_ASSET_NOT_ALLOWED",
|
|
918
|
+
"DELEGATION_PRICING_MISMATCH",
|
|
919
|
+
"DELEGATION_CAPACITY_EXCEEDED",
|
|
920
|
+
"DELEGATION_PENDING_LOCK",
|
|
921
|
+
"DELEGATION_FUNDER_NOT_OFFERER",
|
|
922
|
+
"DELEGATION_ALREADY_FUNDED",
|
|
923
|
+
// work handler (request / respond)
|
|
924
|
+
"WORK_DELEGATION_NOT_FOUND",
|
|
925
|
+
"WORK_DELEGATION_NOT_ACTIVE",
|
|
926
|
+
"WORK_RELATIONSHIP_MISMATCH",
|
|
927
|
+
"WORK_REQUESTER_NOT_OFFERER",
|
|
928
|
+
"WORK_REQUEST_ALREADY_EXISTS",
|
|
929
|
+
"WORK_REQUEST_NOT_FOUND",
|
|
930
|
+
"WORK_RESPONDER_IS_CALLER",
|
|
931
|
+
"WORK_INVALID_STATE",
|
|
932
|
+
// receipt handler (propose)
|
|
933
|
+
"RECEIPT_ALREADY_EXISTS",
|
|
934
|
+
"RECEIPT_DELEGATION_NOT_FOUND",
|
|
935
|
+
"RECEIPT_DELEGATION_NOT_ACTIVE",
|
|
936
|
+
"RECEIPT_RELATIONSHIP_MISMATCH",
|
|
937
|
+
"RECEIPT_ISSUER_IS_CALLER",
|
|
938
|
+
"RECEIPT_NOT_FOUND",
|
|
939
|
+
"RECEIPT_INVALID_STATE",
|
|
940
|
+
"RECEIPT_RESPONSE_HASH_NOT_FOUND",
|
|
941
|
+
"RECEIPT_REQUEST_HASH_NOT_FOUND",
|
|
942
|
+
"RECEIPT_DELIVERABLE_HASH_MISMATCH"
|
|
943
|
+
];
|
|
944
|
+
var POST_COMMIT_ERROR_CODE_PREFIXES = ["ESC_LOCK_", "SDK_"];
|
|
945
|
+
var POST_COMMIT_SET = new Set(POST_COMMIT_ERROR_CODES);
|
|
946
|
+
function isPostCommitErrorCode(code) {
|
|
947
|
+
return POST_COMMIT_SET.has(code) || POST_COMMIT_ERROR_CODE_PREFIXES.some((p) => code.startsWith(p));
|
|
948
|
+
}
|
|
949
|
+
|
|
887
950
|
exports.ASSET_DECIMALS_MAX = ASSET_DECIMALS_MAX;
|
|
888
951
|
exports.ASSET_DECIMALS_MIN = ASSET_DECIMALS_MIN;
|
|
889
952
|
exports.ASSET_SYMBOL_MAX_LEN = ASSET_SYMBOL_MAX_LEN;
|
|
@@ -893,9 +956,12 @@ exports.ASSOCIATED_TOKEN_PROGRAM_ID_BASE58 = ASSOCIATED_TOKEN_PROGRAM_ID_BASE58;
|
|
|
893
956
|
exports.BODY_TYPES = BODY_TYPES;
|
|
894
957
|
exports.BodyTypes = BodyTypes;
|
|
895
958
|
exports.CAIP19_REGEX = CAIP19_REGEX;
|
|
959
|
+
exports.CLI_LOGIN_SESSION_STATES = CLI_LOGIN_SESSION_STATES;
|
|
960
|
+
exports.CLI_LOGIN_SESSION_STORED_STATES = CLI_LOGIN_SESSION_STORED_STATES;
|
|
896
961
|
exports.CREATE_LOCK_DISCRIMINATOR = CREATE_LOCK_DISCRIMINATOR;
|
|
897
962
|
exports.CREATE_LOCK_NATIVE_DISCRIMINATOR = CREATE_LOCK_NATIVE_DISCRIMINATOR;
|
|
898
963
|
exports.CURRENT_PROTOCOL_VERSION = CURRENT_PROTOCOL_VERSION;
|
|
964
|
+
exports.CliLoginSessionStates = CliLoginSessionStates;
|
|
899
965
|
exports.DECIMAL_AMOUNT_REGEX = DECIMAL_AMOUNT_REGEX;
|
|
900
966
|
exports.DECLINE_REASONS = DECLINE_REASONS;
|
|
901
967
|
exports.DELEGATION_ACTIONS = DELEGATION_ACTIONS;
|
|
@@ -921,12 +987,15 @@ exports.LOCK_ACCOUNT_SIZE = LOCK_ACCOUNT_SIZE;
|
|
|
921
987
|
exports.LOCK_STATE_NAMES = LOCK_STATE_NAMES;
|
|
922
988
|
exports.LOCK_TERMINAL_STATES = LOCK_TERMINAL_STATES;
|
|
923
989
|
exports.LockStates = LockStates;
|
|
990
|
+
exports.LockTerminalStates = LockTerminalStates;
|
|
924
991
|
exports.MAINNET_MINTS = MAINNET_MINTS;
|
|
925
992
|
exports.MAX_CLOCK_SKEW_SECONDS = MAX_CLOCK_SKEW_SECONDS;
|
|
926
993
|
exports.MAX_ENVELOPE_TTL_SECONDS = MAX_ENVELOPE_TTL_SECONDS;
|
|
927
994
|
exports.NATIVE_SOL_MINT_BASE58 = NATIVE_SOL_MINT_BASE58;
|
|
928
995
|
exports.NO_ARG_LIFECYCLE_INSTRUCTIONS = NO_ARG_LIFECYCLE_INSTRUCTIONS;
|
|
929
996
|
exports.OWNER_SIGNING_METHODS = OWNER_SIGNING_METHODS;
|
|
997
|
+
exports.POST_COMMIT_ERROR_CODES = POST_COMMIT_ERROR_CODES;
|
|
998
|
+
exports.POST_COMMIT_ERROR_CODE_PREFIXES = POST_COMMIT_ERROR_CODE_PREFIXES;
|
|
930
999
|
exports.PROTOCOL_VERSIONS = PROTOCOL_VERSIONS;
|
|
931
1000
|
exports.Purpose = Purpose;
|
|
932
1001
|
exports.READ_MODEL_STATUSES = READ_MODEL_STATUSES;
|
|
@@ -973,6 +1042,7 @@ exports.getPublicKey = getPublicKey2;
|
|
|
973
1042
|
exports.instructionDiscriminator = instructionDiscriminator;
|
|
974
1043
|
exports.isAssetIdentifier = isAssetIdentifier;
|
|
975
1044
|
exports.isBodyType = isBodyType;
|
|
1045
|
+
exports.isCliLoginSessionWireState = isCliLoginSessionWireState;
|
|
976
1046
|
exports.isDecimalAmountString = isDecimalAmountString;
|
|
977
1047
|
exports.isDeclineReason = isDeclineReason;
|
|
978
1048
|
exports.isDelegationAction = isDelegationAction;
|
|
@@ -981,6 +1051,7 @@ exports.isDiscoverySort = isDiscoverySort;
|
|
|
981
1051
|
exports.isEscrowReleaseMethod = isEscrowReleaseMethod;
|
|
982
1052
|
exports.isHandshakeDecision = isHandshakeDecision;
|
|
983
1053
|
exports.isInboxBlockScope = isInboxBlockScope;
|
|
1054
|
+
exports.isPostCommitErrorCode = isPostCommitErrorCode;
|
|
984
1055
|
exports.isReadModelStatus = isReadModelStatus;
|
|
985
1056
|
exports.isReceiptVerdict = isReceiptVerdict;
|
|
986
1057
|
exports.isRelationshipState = isRelationshipState;
|
package/dist/index.mjs
CHANGED
|
@@ -538,6 +538,19 @@ var InboxBlockScopes = {
|
|
|
538
538
|
DID: "did"
|
|
539
539
|
};
|
|
540
540
|
|
|
541
|
+
// src/types/cli-auth.ts
|
|
542
|
+
var CLI_LOGIN_SESSION_STORED_STATES = ["pending", "confirmed", "consumed"];
|
|
543
|
+
var CLI_LOGIN_SESSION_STATES = ["pending", "confirmed", "consumed", "expired"];
|
|
544
|
+
function isCliLoginSessionWireState(v) {
|
|
545
|
+
return typeof v === "string" && CLI_LOGIN_SESSION_STATES.includes(v);
|
|
546
|
+
}
|
|
547
|
+
var CliLoginSessionStates = {
|
|
548
|
+
PENDING: "pending",
|
|
549
|
+
CONFIRMED: "confirmed",
|
|
550
|
+
CONSUMED: "consumed",
|
|
551
|
+
EXPIRED: "expired"
|
|
552
|
+
};
|
|
553
|
+
|
|
541
554
|
// src/assets.ts
|
|
542
555
|
var SOLANA_CLUSTER_IDS = {
|
|
543
556
|
"solana-mainnet": "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
|
|
@@ -788,6 +801,13 @@ var LOCK_ACCOUNT_SIZE = 269;
|
|
|
788
801
|
var LOCK_ACCOUNT_DISCRIMINATOR = new Uint8Array([8, 255, 36, 202, 210, 22, 57, 137]);
|
|
789
802
|
var LOCK_STATE_NAMES = ["created", "canceled", "in_progress", "submitted", "paid", "revoked", "disputing", "dispute_resolved", "dispute_closed"];
|
|
790
803
|
var LOCK_TERMINAL_STATES = ["canceled", "paid", "revoked", "dispute_resolved", "dispute_closed"];
|
|
804
|
+
var LockTerminalStates = {
|
|
805
|
+
CANCELED: "canceled",
|
|
806
|
+
PAID: "paid",
|
|
807
|
+
REVOKED: "revoked",
|
|
808
|
+
DISPUTE_RESOLVED: "dispute_resolved",
|
|
809
|
+
DISPUTE_CLOSED: "dispute_closed"
|
|
810
|
+
};
|
|
791
811
|
var ESCROW_RELEASE_METHODS = ["buyer_approved", "review_timeout"];
|
|
792
812
|
function isEscrowReleaseMethod(v) {
|
|
793
813
|
return typeof v === "string" && ESCROW_RELEASE_METHODS.includes(v);
|
|
@@ -859,4 +879,47 @@ function readU64LE(buf, off) {
|
|
|
859
879
|
return v;
|
|
860
880
|
}
|
|
861
881
|
|
|
862
|
-
|
|
882
|
+
// src/errors/post-commit.ts
|
|
883
|
+
var POST_COMMIT_ERROR_CODES = [
|
|
884
|
+
// delegation handler (offer / accept / decline / cancel / fund)
|
|
885
|
+
"DELEGATION_ALREADY_EXISTS",
|
|
886
|
+
"DELEGATION_INVALID_STATE",
|
|
887
|
+
"DELEGATION_NOT_FOUND",
|
|
888
|
+
"DELEGATION_RELATIONSHIP_MISMATCH",
|
|
889
|
+
"DELEGATION_ACCEPTER_IS_OFFERER",
|
|
890
|
+
"DELEGATION_DECLINER_IS_OFFERER",
|
|
891
|
+
"DELEGATION_CANCELER_NOT_OFFERER",
|
|
892
|
+
"DELEGATION_ASSET_NOT_ALLOWED",
|
|
893
|
+
"DELEGATION_PRICING_MISMATCH",
|
|
894
|
+
"DELEGATION_CAPACITY_EXCEEDED",
|
|
895
|
+
"DELEGATION_PENDING_LOCK",
|
|
896
|
+
"DELEGATION_FUNDER_NOT_OFFERER",
|
|
897
|
+
"DELEGATION_ALREADY_FUNDED",
|
|
898
|
+
// work handler (request / respond)
|
|
899
|
+
"WORK_DELEGATION_NOT_FOUND",
|
|
900
|
+
"WORK_DELEGATION_NOT_ACTIVE",
|
|
901
|
+
"WORK_RELATIONSHIP_MISMATCH",
|
|
902
|
+
"WORK_REQUESTER_NOT_OFFERER",
|
|
903
|
+
"WORK_REQUEST_ALREADY_EXISTS",
|
|
904
|
+
"WORK_REQUEST_NOT_FOUND",
|
|
905
|
+
"WORK_RESPONDER_IS_CALLER",
|
|
906
|
+
"WORK_INVALID_STATE",
|
|
907
|
+
// receipt handler (propose)
|
|
908
|
+
"RECEIPT_ALREADY_EXISTS",
|
|
909
|
+
"RECEIPT_DELEGATION_NOT_FOUND",
|
|
910
|
+
"RECEIPT_DELEGATION_NOT_ACTIVE",
|
|
911
|
+
"RECEIPT_RELATIONSHIP_MISMATCH",
|
|
912
|
+
"RECEIPT_ISSUER_IS_CALLER",
|
|
913
|
+
"RECEIPT_NOT_FOUND",
|
|
914
|
+
"RECEIPT_INVALID_STATE",
|
|
915
|
+
"RECEIPT_RESPONSE_HASH_NOT_FOUND",
|
|
916
|
+
"RECEIPT_REQUEST_HASH_NOT_FOUND",
|
|
917
|
+
"RECEIPT_DELIVERABLE_HASH_MISMATCH"
|
|
918
|
+
];
|
|
919
|
+
var POST_COMMIT_ERROR_CODE_PREFIXES = ["ESC_LOCK_", "SDK_"];
|
|
920
|
+
var POST_COMMIT_SET = new Set(POST_COMMIT_ERROR_CODES);
|
|
921
|
+
function isPostCommitErrorCode(code) {
|
|
922
|
+
return POST_COMMIT_SET.has(code) || POST_COMMIT_ERROR_CODE_PREFIXES.some((p) => code.startsWith(p));
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
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, CLI_LOGIN_SESSION_STATES, CLI_LOGIN_SESSION_STORED_STATES, CREATE_LOCK_DISCRIMINATOR, CREATE_LOCK_NATIVE_DISCRIMINATOR, CURRENT_PROTOCOL_VERSION, CliLoginSessionStates, 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, isCliLoginSessionWireState, 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 };
|
package/dist/types/agent.d.ts
CHANGED
|
@@ -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,105 @@ 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
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Request body for `POST /v1/agents` (registration). The server DTO is
|
|
141
|
+
* `RegisterAgentDto`; `ownerAttestation` mirrors the SDK
|
|
142
|
+
* `ScryptPasswordAttestation<KeyLinkPayload>` wire shape but stays a
|
|
143
|
+
* generic object here — its inner fields are verified by canonical-JSON
|
|
144
|
+
* + HMAC at the server, not structurally.
|
|
145
|
+
*/
|
|
146
|
+
export interface RegisterAgentRequest {
|
|
147
|
+
challengeId: string;
|
|
148
|
+
identityPublicKey: string;
|
|
149
|
+
settlementPublicKey: string;
|
|
150
|
+
ownerAttestation: {
|
|
151
|
+
payload: Record<string, unknown>;
|
|
152
|
+
sig: string;
|
|
153
|
+
scrypt_salt_id: string;
|
|
154
|
+
};
|
|
155
|
+
scryptKeyB64: string;
|
|
156
|
+
scryptSaltB64: string;
|
|
157
|
+
name?: string;
|
|
158
|
+
description?: string;
|
|
159
|
+
/** Capability tags — lowercase alphanumeric + dash/underscore, max 20. */
|
|
160
|
+
tags?: string[];
|
|
161
|
+
}
|
package/dist/types/cli-auth.d.ts
CHANGED
|
@@ -4,12 +4,36 @@
|
|
|
4
4
|
* CLI's response types — both are plain framework-agnostic interfaces
|
|
5
5
|
* (the server declares them in a service, not a NestJS DTO class), so
|
|
6
6
|
* this is a pure lift-and-share with no decorator coupling.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* `heyarp login` session lifecycle. TWO tiers because the wire vocab is
|
|
10
|
+
* a strict superset of what's persisted:
|
|
11
|
+
*
|
|
12
|
+
* - {@link CLI_LOGIN_SESSION_STORED_STATES} — what the server's Mongo
|
|
13
|
+
* row actually holds (`@Prop enum`): `pending` → `confirmed` →
|
|
14
|
+
* `consumed`.
|
|
15
|
+
* - {@link CLI_LOGIN_SESSION_STATES} — what the `GET …/sessions/:id`
|
|
16
|
+
* endpoint can RETURN. Adds `expired`, which the service COMPUTES on
|
|
17
|
+
* read for a `pending` row past its TTL (and the CLI also derives
|
|
18
|
+
* from a 404). `expired` is never stored.
|
|
7
19
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
20
|
+
* Same `as const` array + union + guard + const-object shape as the
|
|
21
|
+
* protocol vocabularies; the server sources its `@Prop enum` from the
|
|
22
|
+
* stored array and types the read endpoint with the full wire union,
|
|
23
|
+
* and the CLI types its wire response from the full union.
|
|
12
24
|
*/
|
|
25
|
+
export declare const CLI_LOGIN_SESSION_STORED_STATES: readonly ["pending", "confirmed", "consumed"];
|
|
26
|
+
export type CliLoginSessionStoredState = (typeof CLI_LOGIN_SESSION_STORED_STATES)[number];
|
|
27
|
+
export declare const CLI_LOGIN_SESSION_STATES: readonly ["pending", "confirmed", "consumed", "expired"];
|
|
28
|
+
export type CliLoginSessionWireState = (typeof CLI_LOGIN_SESSION_STATES)[number];
|
|
29
|
+
export declare function isCliLoginSessionWireState(v: unknown): v is CliLoginSessionWireState;
|
|
30
|
+
/** Named-member accessor for {@link CliLoginSessionWireState} (vocab-tested). */
|
|
31
|
+
export declare const CliLoginSessionStates: {
|
|
32
|
+
readonly PENDING: "pending";
|
|
33
|
+
readonly CONFIRMED: "confirmed";
|
|
34
|
+
readonly CONSUMED: "consumed";
|
|
35
|
+
readonly EXPIRED: "expired";
|
|
36
|
+
};
|
|
13
37
|
/** `POST /v1/auth/cli/sessions` → a new login session. */
|
|
14
38
|
export interface CliSessionCreated {
|
|
15
39
|
sessionId: string;
|
|
@@ -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,95 @@ export declare const DiscoverySorts: {
|
|
|
16
17
|
readonly RECENT: "recent";
|
|
17
18
|
readonly CREATED: "created";
|
|
18
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Query for `GET /v1/discovery/search` (server DTO
|
|
22
|
+
* `DiscoverySearchQueryDto`). Every field optional; filters AND-compose.
|
|
23
|
+
* Reputation is a SOFT sort, never a gate.
|
|
24
|
+
*/
|
|
25
|
+
export interface DiscoverySearchQuery {
|
|
26
|
+
/** Full-text over name + description. */
|
|
27
|
+
q?: string;
|
|
28
|
+
/** Capability tags — AND-require all. */
|
|
29
|
+
tag?: string[];
|
|
30
|
+
/** Creator wallet (base58) — you must already know it; never echoed back. */
|
|
31
|
+
accountId?: string;
|
|
32
|
+
/** CAIP-19 payment asset; matches explicit listers AND accept-anything agents. */
|
|
33
|
+
accepts?: string;
|
|
34
|
+
/** Only agents seen within the liveness window. */
|
|
35
|
+
online?: boolean;
|
|
36
|
+
/** `reputation` (composite desc, default) | `recent` | `created` (cursor). */
|
|
37
|
+
sort?: DiscoverySort;
|
|
38
|
+
/** Zero-based page index (offset = page × limit) — reputation/recent sorts. */
|
|
39
|
+
page?: number;
|
|
40
|
+
/** Cursor for `sort=created`: the previous page's last row id. */
|
|
41
|
+
after?: string;
|
|
42
|
+
limit?: number;
|
|
43
|
+
}
|
|
44
|
+
/** Reputation digest carried inline on each discovery row (the soft-sort key). */
|
|
45
|
+
export interface DiscoveryReputation {
|
|
46
|
+
composite: number;
|
|
47
|
+
reliability: number;
|
|
48
|
+
settlement: number;
|
|
49
|
+
disputeHealth: number;
|
|
50
|
+
computed: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** Liveness digest — how recently / whether the agent is reachable. */
|
|
53
|
+
export interface DiscoveryLiveness {
|
|
54
|
+
/** Durable: a signed request within the liveness window (replica-accurate). */
|
|
55
|
+
online: boolean;
|
|
56
|
+
/** Live: an open SSE inbox stream on the serving instance (per-process). */
|
|
57
|
+
inboxStreamActive: boolean;
|
|
58
|
+
/** RFC 3339 of the last signed request; null ⇒ never seen since registration. */
|
|
59
|
+
lastSeenAt?: string | null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* One discovery search row — a privacy-safe subset of the agent
|
|
63
|
+
* profile (NO accountId / key material) enriched with the reputation
|
|
64
|
+
* soft-sort key + liveness.
|
|
65
|
+
*/
|
|
66
|
+
export interface DiscoveryResult {
|
|
67
|
+
id: string;
|
|
68
|
+
did: string;
|
|
69
|
+
name?: string;
|
|
70
|
+
description?: string;
|
|
71
|
+
tags: string[];
|
|
72
|
+
acceptPrefs?: AcceptPrefs;
|
|
73
|
+
reputation: DiscoveryReputation;
|
|
74
|
+
liveness: DiscoveryLiveness;
|
|
75
|
+
registeredAt: string;
|
|
76
|
+
}
|
|
77
|
+
/** Pagination envelope metadata on a discovery search page. */
|
|
78
|
+
export interface DiscoveryPagination {
|
|
79
|
+
/** Count of ALL agents matching the filters (ignores the page window). */
|
|
80
|
+
total: number;
|
|
81
|
+
limit: number;
|
|
82
|
+
/** ceil(total / limit). */
|
|
83
|
+
totalPages: number;
|
|
84
|
+
hasMore: boolean;
|
|
85
|
+
/** Zero-based page index — offset sorts (reputation / recent) only. */
|
|
86
|
+
page?: number;
|
|
87
|
+
/** Cursor for the next page — `sort=created` only, when hasMore (pass as `after`). */
|
|
88
|
+
nextCursor?: string | null;
|
|
89
|
+
}
|
|
90
|
+
/** `GET /v1/discovery/search` response — a page of rows + pagination metadata. */
|
|
91
|
+
export interface DiscoverySearchResponse {
|
|
92
|
+
results: DiscoveryResult[];
|
|
93
|
+
pagination: DiscoveryPagination;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* `GET /v1/discovery/agents/:did/profile` — the composed single-agent
|
|
97
|
+
* view: public profile + full reputation + liveness in one read.
|
|
98
|
+
*/
|
|
99
|
+
export interface DiscoveryProfile {
|
|
100
|
+
did: string;
|
|
101
|
+
name?: string;
|
|
102
|
+
description?: string;
|
|
103
|
+
tags: string[];
|
|
104
|
+
acceptPrefs?: AcceptPrefs;
|
|
105
|
+
registeredAt: string;
|
|
106
|
+
reputation: AgentReputation;
|
|
107
|
+
/** Liveness, plus `lastEventAt` (last protocol event either side). */
|
|
108
|
+
liveness: DiscoveryLiveness & {
|
|
109
|
+
lastEventAt?: string | null;
|
|
110
|
+
};
|
|
111
|
+
}
|
package/dist/types/inbox.d.ts
CHANGED
|
@@ -15,3 +15,32 @@ 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
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Body for `POST /v1/inbox/blocks` (server DTO `CreateInboxBlockDto`).
|
|
36
|
+
* You always NAME a DID; by default the server resolves its owner and
|
|
37
|
+
* blocks every sibling agent (account scope). The target account id is
|
|
38
|
+
* never returned.
|
|
39
|
+
*/
|
|
40
|
+
export interface BlockInboxBody {
|
|
41
|
+
did: string;
|
|
42
|
+
/** Block only this exact DID instead of the whole owner account. */
|
|
43
|
+
didOnly?: boolean;
|
|
44
|
+
/** Optional private note (max 512 chars). Visible only to you. */
|
|
45
|
+
reason?: string;
|
|
46
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,11 +10,13 @@ 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, DiscoverySearchQuery, 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, BlockInboxBody } from './inbox';
|
|
16
16
|
export { INBOX_BLOCK_SCOPES, InboxBlockScopes, isInboxBlockScope } from './inbox';
|
|
17
|
-
export type { CliSessionCreated, CliTokenIssued, CliWhoami, MyAgentSummary } from './cli-auth';
|
|
18
|
-
export
|
|
17
|
+
export type { CliSessionCreated, CliTokenIssued, CliWhoami, MyAgentSummary, CliLoginSessionStoredState, CliLoginSessionWireState, } from './cli-auth';
|
|
18
|
+
export { CLI_LOGIN_SESSION_STORED_STATES, CLI_LOGIN_SESSION_STATES, CliLoginSessionStates, isCliLoginSessionWireState } from './cli-auth';
|
|
19
|
+
export type { AssetIdentifierWire, DelegationPublic, ReceiptPublic, RelationshipPublic, WorkLogPublic, EventPublic, IngestResult } from './read-model';
|
|
20
|
+
export type { AcceptPrefs, AcceptCurrency, AgentRegisteredResponse, AgentPublic, UpdateAgentBody, RegisterAgentRequest, ReputationScores, ReputationCounters, AgentReputation, } from './agent';
|
|
19
21
|
export type { OwnerSigningMethod, KeyLinkPayload, ScryptPasswordAttestation } from './identity';
|
|
20
22
|
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.
|
|
3
|
+
"version": "0.0.24",
|
|
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": [
|