@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.
@@ -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
+ }
@@ -14,3 +14,14 @@ export type RelationshipState = (typeof RELATIONSHIP_STATE_NAMES)[number];
14
14
  */
15
15
  export declare const LIVE_RELATIONSHIP_STATE_NAMES: readonly ["pending", "active", "paused"];
16
16
  export declare function isRelationshipState(v: unknown): v is RelationshipState;
17
+ /**
18
+ * Named-member accessor for the relationship FSM (see
19
+ * {@link DelegationStates} for the rationale). Values are the wire
20
+ * strings; parity with {@link RELATIONSHIP_STATE_NAMES} is vocab-tested.
21
+ */
22
+ export declare const RelationshipStates: {
23
+ readonly PENDING: "pending";
24
+ readonly ACTIVE: "active";
25
+ readonly PAUSED: "paused";
26
+ readonly CLOSED: "closed";
27
+ };
@@ -8,3 +8,11 @@
8
8
  export declare const WORK_LOG_STATES: readonly ["requested", "responded"];
9
9
  export type WorkLogState = (typeof WORK_LOG_STATES)[number];
10
10
  export declare function isWorkLogState(v: unknown): v is WorkLogState;
11
+ /**
12
+ * Named-member accessor for the work-log FSM (see {@link WORK_LOG_STATES}).
13
+ * Values are the wire strings; parity is vocab-tested.
14
+ */
15
+ export declare const WorkLogStates: {
16
+ readonly REQUESTED: "requested";
17
+ readonly RESPONDED: "responded";
18
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyanon-arp/sdk",
3
- "version": "0.0.15",
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": [