@agenticprimitives/agent-relationships 0.1.0-alpha.2

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/client.js ADDED
@@ -0,0 +1,227 @@
1
+ import { createPublicClient, http } from 'viem';
2
+ import { agentRelationshipAbi } from './abis';
3
+ import { buildAddRoleCall, buildConfirmEdgeCall, buildProposeEdgeCall, buildRemoveRoleCall, buildRevokeEdgeCall, } from './calls';
4
+ import { computeEdgeId } from './edge-id';
5
+ import { UnknownRelationshipTypeError } from './errors';
6
+ const ZERO = '0x0000000000000000000000000000000000000000';
7
+ const ZERO_NODE = '0x0000000000000000000000000000000000000000000000000000000000000000';
8
+ export class AgentRelationshipsClient {
9
+ opts;
10
+ publicClient;
11
+ relationships;
12
+ constructor(opts) {
13
+ this.opts = opts;
14
+ if (!opts.rpcUrl)
15
+ throw new Error('[agent-relationships] rpcUrl required');
16
+ if (typeof opts.chainId !== 'number') {
17
+ throw new Error('[agent-relationships] chainId required');
18
+ }
19
+ if (!opts.relationships) {
20
+ throw new Error('[agent-relationships] relationships address required');
21
+ }
22
+ this.publicClient = createPublicClient({ transport: http(opts.rpcUrl) });
23
+ this.relationships = opts.relationships;
24
+ }
25
+ // ─── Reads (Phase 2 — live) ─────────────────────────────────────
26
+ /** Fetch a single edge by ID. Returns `null` when no such edge. */
27
+ async getEdge(edgeId) {
28
+ if (edgeId === ZERO_NODE)
29
+ return null;
30
+ const exists = await this.publicClient.readContract({
31
+ address: this.relationships,
32
+ abi: agentRelationshipAbi,
33
+ functionName: 'edgeExists',
34
+ args: [edgeId],
35
+ });
36
+ if (!exists)
37
+ return null;
38
+ const tuple = await this.publicClient.readContract({
39
+ address: this.relationships,
40
+ abi: agentRelationshipAbi,
41
+ functionName: 'getEdge',
42
+ args: [edgeId],
43
+ });
44
+ const roles = await this.publicClient.readContract({
45
+ address: this.relationships,
46
+ abi: agentRelationshipAbi,
47
+ functionName: 'getRoles',
48
+ args: [edgeId],
49
+ });
50
+ return _toEdge(tuple, roles);
51
+ }
52
+ /**
53
+ * List edges where `subject` appears on the subject side. Optional
54
+ * client-side filter by `relationshipType` and/or `status`.
55
+ *
56
+ * Order is contract-insertion order. Each edge is fetched in
57
+ * parallel via getEdge.
58
+ */
59
+ async listEdgesFor(subject, filter) {
60
+ const ids = await this.publicClient.readContract({
61
+ address: this.relationships,
62
+ abi: agentRelationshipAbi,
63
+ functionName: 'getEdgesBySubject',
64
+ args: [subject],
65
+ });
66
+ const edges = (await Promise.all(ids.map((id) => this.getEdge(id)))).filter((e) => e !== null);
67
+ return edges.filter((e) => {
68
+ if (filter?.relationshipType && e.relationshipType !== filter.relationshipType)
69
+ return false;
70
+ if (filter?.status !== undefined && e.status !== filter.status)
71
+ return false;
72
+ return true;
73
+ });
74
+ }
75
+ /** Same as `listEdgesFor` but on the object side. */
76
+ async listEdgesPointingAt(object, filter) {
77
+ const ids = await this.publicClient.readContract({
78
+ address: this.relationships,
79
+ abi: agentRelationshipAbi,
80
+ functionName: 'getEdgesByObject',
81
+ args: [object],
82
+ });
83
+ const edges = (await Promise.all(ids.map((id) => this.getEdge(id)))).filter((e) => e !== null);
84
+ return edges.filter((e) => {
85
+ if (filter?.relationshipType && e.relationshipType !== filter.relationshipType)
86
+ return false;
87
+ if (filter?.status !== undefined && e.status !== filter.status)
88
+ return false;
89
+ return true;
90
+ });
91
+ }
92
+ // ─── Writes (Phase 4 — live) ─────────────────────────────────────
93
+ /**
94
+ * Propose a new edge. The walletClient's account MUST equal
95
+ * `input.subject` — the contract enforces `msg.sender == subject`.
96
+ * Returns the propose tx hash. The edgeId can be computed
97
+ * off-chain via `computeEdgeId(subject, object, relationshipType)`
98
+ * (matches the on-chain `keccak256(abi.encodePacked(...))`
99
+ * derivation).
100
+ *
101
+ * For PSA-controlled proposals (subject is a Smart Agent gated by
102
+ * CustodyPolicy), use `buildProposeEdgeCall` directly and compose
103
+ * into your AgentAccount.execute / CustodyPolicy ceremony.
104
+ */
105
+ async proposeEdge(input, ctx) {
106
+ const call = buildProposeEdgeCall({
107
+ relationships: this.relationships,
108
+ subject: input.subject,
109
+ object: input.object,
110
+ relationshipType: input.relationshipType,
111
+ initialRoles: input.subjectRoles,
112
+ metadataURI: input.metadataUri,
113
+ metadataHash: input.metadataHash,
114
+ });
115
+ return await this._submit(ctx, call);
116
+ }
117
+ /**
118
+ * Confirm a PROPOSED edge. The walletClient's account MUST equal
119
+ * the object side (msg.sender == object on chain).
120
+ */
121
+ async confirmEdge(input, ctx) {
122
+ const call = buildConfirmEdgeCall({ relationships: this.relationships, edgeId: input.edgeId });
123
+ return await this._submit(ctx, call);
124
+ }
125
+ /**
126
+ * Revoke an edge. Either party may revoke unilaterally (contract
127
+ * checks `msg.sender == subject || msg.sender == object`).
128
+ */
129
+ async revokeEdge(input, ctx) {
130
+ const call = buildRevokeEdgeCall({ relationships: this.relationships, edgeId: input.edgeId });
131
+ return await this._submit(ctx, call);
132
+ }
133
+ /**
134
+ * Add / remove roles on an existing edge. Either party may modify
135
+ * the edge's role bag.
136
+ *
137
+ * Note: the on-chain `Edge` has a single role bag (no subject/object
138
+ * separation in storage); `SetRolesInput.subjectRoles` +
139
+ * `objectRoles` are coalesced into the same bag. The current set
140
+ * is computed via `getRoles(edgeId)` and the diff is submitted as
141
+ * N add / remove txs.
142
+ */
143
+ async setRoles(input, ctx) {
144
+ const desiredArr = [
145
+ ...(input.subjectRoles ?? []),
146
+ ...(input.objectRoles ?? []),
147
+ ];
148
+ const current = await this.publicClient.readContract({
149
+ address: this.relationships,
150
+ abi: agentRelationshipAbi,
151
+ functionName: 'getRoles',
152
+ args: [input.edgeId],
153
+ });
154
+ const desired = new Set(desiredArr.map((r) => r.toLowerCase()));
155
+ const existing = new Set([...current].map((r) => r.toLowerCase()));
156
+ const toAdd = desiredArr.filter((r) => !existing.has(r.toLowerCase()));
157
+ const toRemove = [...current].filter((r) => !desired.has(r.toLowerCase()));
158
+ const hashes = [];
159
+ for (const role of toAdd) {
160
+ hashes.push(await this._submit(ctx, buildAddRoleCall({ relationships: this.relationships, edgeId: input.edgeId, role: role })));
161
+ }
162
+ for (const role of toRemove) {
163
+ hashes.push(await this._submit(ctx, buildRemoveRoleCall({ relationships: this.relationships, edgeId: input.edgeId, role: role })));
164
+ }
165
+ return hashes;
166
+ }
167
+ /**
168
+ * Submit a single ContractCall via the bound walletClient. Uses
169
+ * explicit nonce fetch + retry on "replacement underpriced" to
170
+ * tolerate Base Sepolia's read-after-write lag.
171
+ */
172
+ async _submit(ctx, call) {
173
+ const { walletClient } = ctx;
174
+ const account = walletClient.account;
175
+ if (!account)
176
+ throw new Error('[agent-relationships] walletClient has no account');
177
+ let lastErr;
178
+ for (let attempt = 0; attempt < 3; attempt++) {
179
+ try {
180
+ const nonce = await this.publicClient.getTransactionCount({
181
+ address: account.address,
182
+ blockTag: 'pending',
183
+ });
184
+ const hash = await walletClient.sendTransaction({
185
+ to: call.to,
186
+ value: call.value,
187
+ data: call.data,
188
+ nonce,
189
+ account: walletClient.account,
190
+ chain: walletClient.chain ?? null,
191
+ });
192
+ await this.publicClient.waitForTransactionReceipt({ hash });
193
+ return hash;
194
+ }
195
+ catch (err) {
196
+ lastErr = err;
197
+ const msg = err.message ?? '';
198
+ if (msg.includes('replacement') || msg.includes('underpriced')) {
199
+ await new Promise((r) => setTimeout(r, 2000));
200
+ continue;
201
+ }
202
+ throw err;
203
+ }
204
+ }
205
+ throw lastErr instanceof Error ? lastErr : new Error('[agent-relationships] _submit: exceeded retries');
206
+ }
207
+ }
208
+ /** Re-export for callers that want to compute edge IDs off-chain. */
209
+ export { computeEdgeId };
210
+ function _toEdge(t, roles) {
211
+ if (t.subject === ZERO || t.object_ === ZERO) {
212
+ throw new UnknownRelationshipTypeError(t.relationshipType);
213
+ }
214
+ return {
215
+ edgeId: t.edgeId,
216
+ subject: t.subject,
217
+ object: t.object_,
218
+ relationshipType: t.relationshipType,
219
+ subjectRoles: [...roles],
220
+ objectRoles: [],
221
+ status: t.status,
222
+ metadataUri: t.metadataURI || undefined,
223
+ metadataHash: t.metadataHash === ZERO_NODE ? undefined : t.metadataHash,
224
+ createdAt: Number(t.createdAt),
225
+ };
226
+ }
227
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,IAAI,EAAgE,MAAM,MAAM,CAAC;AAC9G,OAAO,EAAE,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAW1C,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAaxD,MAAM,IAAI,GAAG,4CAAqD,CAAC;AACnE,MAAM,SAAS,GAAG,oEAA6E,CAAC;AAkBhG,MAAM,OAAO,wBAAwB;IAId;IAHJ,YAAY,CAAe;IAC3B,aAAa,CAAU;IAExC,YAAqB,IAAsC;QAAtC,SAAI,GAAJ,IAAI,CAAkC;QACzD,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;QAC3E,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,EAAE,CAAC;YACrC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAC5D,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,CAAC,YAAY,GAAG,kBAAkB,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACzE,IAAI,CAAC,aAAa,GAAG,IAAI,CAA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C,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY;QACvE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;KAC/B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Derive a bytes32 ID for a relationship-type name. We hash the raw
3
+ * UTF-8 bytes (matches Solidity `keccak256(bytes(name))`).
4
+ * Done at module load so the constants are static `0x...` strings.
5
+ */
6
+ export declare function hashRelationshipType(name: string): `0x${string}`;
7
+ /**
8
+ * Derive a bytes32 ID for a role name. Same convention as
9
+ * `hashRelationshipType` — distinct helper so call sites read clearly.
10
+ */
11
+ export declare function hashRole(name: string): `0x${string}`;
12
+ /**
13
+ * Well-known relationship types. Values are `keccak256(name)` —
14
+ * deterministic across deployments, so the off-chain Edge IDs always
15
+ * match the on-chain ones.
16
+ *
17
+ * IMPORTANT (ADR-0006): `NAMESPACE_CONTAINS` is intentionally absent.
18
+ * Naming hierarchy lives in agent-naming via a parent-pointer, NOT
19
+ * via a relationships-edge.
20
+ */
21
+ export declare const RELATIONSHIP_TYPE: {
22
+ /** Membership: subject is a member of object (org / DAO / collective). */
23
+ readonly HAS_MEMBER: `0x${string}`;
24
+ /** Governance: subject has governance authority over object. */
25
+ readonly HAS_GOVERNANCE_OVER: `0x${string}`;
26
+ /** Validation trust: subject trusts object as a validator / verifier. */
27
+ readonly VALIDATION_TRUST: `0x${string}`;
28
+ /** Bilateral partnership / cross-recognition. */
29
+ readonly PARTNERSHIP: `0x${string}`;
30
+ /** Marker that subject acts on behalf of object. */
31
+ readonly OPERATES_ON_BEHALF_OF: `0x${string}`;
32
+ /** Recommendation: subject endorses / recommends object. */
33
+ readonly RECOMMENDS: `0x${string}`;
34
+ };
35
+ /** Well-known role labels (bytes32-hashed). */
36
+ export declare const ROLE: {
37
+ /** Generic member role. */
38
+ readonly MEMBER: `0x${string}`;
39
+ /** Board / governance member. */
40
+ readonly BOARD_MEMBER: `0x${string}`;
41
+ /** Operational executor. */
42
+ readonly OPERATOR: `0x${string}`;
43
+ /** Validator / verifier. */
44
+ readonly VALIDATOR: `0x${string}`;
45
+ /** Treasurer (holds the asset account). */
46
+ readonly TREASURER: `0x${string}`;
47
+ /** Recovery contact. */
48
+ readonly RECOVERY_CONTACT: `0x${string}`;
49
+ };
50
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,MAAM,EAAE,CAEhE;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,MAAM,EAAE,CAEpD;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB;IAC5B,0EAA0E;;IAE1E,gEAAgE;;IAEhE,yEAAyE;;IAEzE,iDAAiD;;IAEjD,oDAAoD;;IAEpD,4DAA4D;;CAEpD,CAAC;AAEX,+CAA+C;AAC/C,eAAO,MAAM,IAAI;IACf,2BAA2B;;IAE3B,iCAAiC;;IAEjC,4BAA4B;;IAE5B,4BAA4B;;IAE5B,2CAA2C;;IAE3C,wBAAwB;;CAEhB,CAAC"}
@@ -0,0 +1,55 @@
1
+ import { keccak256, toHex } from 'viem';
2
+ /**
3
+ * Derive a bytes32 ID for a relationship-type name. We hash the raw
4
+ * UTF-8 bytes (matches Solidity `keccak256(bytes(name))`).
5
+ * Done at module load so the constants are static `0x...` strings.
6
+ */
7
+ export function hashRelationshipType(name) {
8
+ return keccak256(toHex(name));
9
+ }
10
+ /**
11
+ * Derive a bytes32 ID for a role name. Same convention as
12
+ * `hashRelationshipType` — distinct helper so call sites read clearly.
13
+ */
14
+ export function hashRole(name) {
15
+ return keccak256(toHex(name));
16
+ }
17
+ /**
18
+ * Well-known relationship types. Values are `keccak256(name)` —
19
+ * deterministic across deployments, so the off-chain Edge IDs always
20
+ * match the on-chain ones.
21
+ *
22
+ * IMPORTANT (ADR-0006): `NAMESPACE_CONTAINS` is intentionally absent.
23
+ * Naming hierarchy lives in agent-naming via a parent-pointer, NOT
24
+ * via a relationships-edge.
25
+ */
26
+ export const RELATIONSHIP_TYPE = {
27
+ /** Membership: subject is a member of object (org / DAO / collective). */
28
+ HAS_MEMBER: hashRelationshipType('HAS_MEMBER'),
29
+ /** Governance: subject has governance authority over object. */
30
+ HAS_GOVERNANCE_OVER: hashRelationshipType('HAS_GOVERNANCE_OVER'),
31
+ /** Validation trust: subject trusts object as a validator / verifier. */
32
+ VALIDATION_TRUST: hashRelationshipType('VALIDATION_TRUST'),
33
+ /** Bilateral partnership / cross-recognition. */
34
+ PARTNERSHIP: hashRelationshipType('PARTNERSHIP'),
35
+ /** Marker that subject acts on behalf of object. */
36
+ OPERATES_ON_BEHALF_OF: hashRelationshipType('OPERATES_ON_BEHALF_OF'),
37
+ /** Recommendation: subject endorses / recommends object. */
38
+ RECOMMENDS: hashRelationshipType('RECOMMENDS'),
39
+ };
40
+ /** Well-known role labels (bytes32-hashed). */
41
+ export const ROLE = {
42
+ /** Generic member role. */
43
+ MEMBER: hashRole('MEMBER'),
44
+ /** Board / governance member. */
45
+ BOARD_MEMBER: hashRole('BOARD_MEMBER'),
46
+ /** Operational executor. */
47
+ OPERATOR: hashRole('OPERATOR'),
48
+ /** Validator / verifier. */
49
+ VALIDATOR: hashRole('VALIDATOR'),
50
+ /** Treasurer (holds the asset account). */
51
+ TREASURER: hashRole('TREASURER'),
52
+ /** Recovery contact. */
53
+ RECOVERY_CONTACT: hashRole('RECOVERY_CONTACT'),
54
+ };
55
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAExC;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AAChC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY;IACnC,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,0EAA0E;IAC1E,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC;IAC9C,gEAAgE;IAChE,mBAAmB,EAAE,oBAAoB,CAAC,qBAAqB,CAAC;IAChE,yEAAyE;IACzE,gBAAgB,EAAE,oBAAoB,CAAC,kBAAkB,CAAC;IAC1D,iDAAiD;IACjD,WAAW,EAAE,oBAAoB,CAAC,aAAa,CAAC;IAChD,oDAAoD;IACpD,qBAAqB,EAAE,oBAAoB,CAAC,uBAAuB,CAAC;IACpE,4DAA4D;IAC5D,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC;CACtC,CAAC;AAEX,+CAA+C;AAC/C,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,2BAA2B;IAC3B,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC;IAC1B,iCAAiC;IACjC,YAAY,EAAE,QAAQ,CAAC,cAAc,CAAC;IACtC,4BAA4B;IAC5B,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC;IAC9B,4BAA4B;IAC5B,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC;IAChC,2CAA2C;IAC3C,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC;IAChC,wBAAwB;IACxB,gBAAgB,EAAE,QAAQ,CAAC,kBAAkB,CAAC;CACtC,CAAC"}
@@ -0,0 +1,15 @@
1
+ import type { Address, Hex } from '@agenticprimitives/types';
2
+ import type { RelationshipType } from './types';
3
+ /**
4
+ * Deterministic edge-ID derivation. Matches the on-chain port that
5
+ * will land in `packages/contracts/src/relationships/AgentRelationship.sol`
6
+ * (Phase 3): `keccak256(abi.encodePacked(subject, object, relType))`.
7
+ *
8
+ * Solidity `address` is a 20-byte value with no casing — we lowercase
9
+ * each input so two callers using different casings (and the on-chain
10
+ * port) produce identical IDs. We deliberately do NOT route through
11
+ * `viem.getAddress`, which requires either all-lowercase OR a valid
12
+ * EIP-55 checksum and rejects all-uppercase.
13
+ */
14
+ export declare function computeEdgeId(subject: Address, object: Address, relationshipType: RelationshipType): Hex;
15
+ //# sourceMappingURL=edge-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edge-id.d.ts","sourceRoot":"","sources":["../src/edge-id.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAKhD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,OAAO,EACf,gBAAgB,EAAE,gBAAgB,GACjC,GAAG,CAcL"}
@@ -0,0 +1,34 @@
1
+ import { keccak256, concat } from 'viem';
2
+ import { InvalidEdgeError } from './errors';
3
+ const ADDRESS_RE = /^0x[0-9a-fA-F]{40}$/;
4
+ /**
5
+ * Deterministic edge-ID derivation. Matches the on-chain port that
6
+ * will land in `packages/contracts/src/relationships/AgentRelationship.sol`
7
+ * (Phase 3): `keccak256(abi.encodePacked(subject, object, relType))`.
8
+ *
9
+ * Solidity `address` is a 20-byte value with no casing — we lowercase
10
+ * each input so two callers using different casings (and the on-chain
11
+ * port) produce identical IDs. We deliberately do NOT route through
12
+ * `viem.getAddress`, which requires either all-lowercase OR a valid
13
+ * EIP-55 checksum and rejects all-uppercase.
14
+ */
15
+ export function computeEdgeId(subject, object, relationshipType) {
16
+ if (!subject)
17
+ throw new InvalidEdgeError('subject required', 'subject');
18
+ if (!object)
19
+ throw new InvalidEdgeError('object required', 'object');
20
+ if (!relationshipType) {
21
+ throw new InvalidEdgeError('relationshipType required', 'relationshipType');
22
+ }
23
+ if (!ADDRESS_RE.test(subject))
24
+ throw new InvalidEdgeError(`malformed subject ${subject}`, 'subject');
25
+ if (!ADDRESS_RE.test(object))
26
+ throw new InvalidEdgeError(`malformed object ${object}`, 'object');
27
+ if (subject.toLowerCase() === object.toLowerCase()) {
28
+ throw new InvalidEdgeError('subject and object must differ — self-edges not allowed');
29
+ }
30
+ const s = subject.toLowerCase();
31
+ const o = object.toLowerCase();
32
+ return keccak256(concat([s, o, relationshipType]));
33
+ }
34
+ //# sourceMappingURL=edge-id.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"edge-id.js","sourceRoot":"","sources":["../src/edge-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAGzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAC3B,OAAgB,EAChB,MAAe,EACf,gBAAkC;IAElC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,gBAAgB,CAAC,kBAAkB,EAAE,SAAS,CAAC,CAAC;IACxE,IAAI,CAAC,MAAM;QAAE,MAAM,IAAI,gBAAgB,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC;IACrE,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,gBAAgB,CAAC,2BAA2B,EAAE,kBAAkB,CAAC,CAAC;IAC9E,CAAC;IACD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC;QAAE,MAAM,IAAI,gBAAgB,CAAC,qBAAqB,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;IACrG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,gBAAgB,CAAC,oBAAoB,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAC;IACjG,IAAI,OAAO,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;QACnD,MAAM,IAAI,gBAAgB,CAAC,yDAAyD,CAAC,CAAC;IACxF,CAAC;IACD,MAAM,CAAC,GAAG,OAAO,CAAC,WAAW,EAAmB,CAAC;IACjD,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,EAAmB,CAAC;IAChD,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC"}
@@ -0,0 +1,15 @@
1
+ export declare class InvalidEdgeError extends Error {
2
+ readonly reason: string;
3
+ readonly field?: string | undefined;
4
+ constructor(reason: string, field?: string | undefined);
5
+ }
6
+ export declare class UnauthorizedActorError extends Error {
7
+ readonly actor: string;
8
+ readonly action: string;
9
+ constructor(actor: string, action: string);
10
+ }
11
+ export declare class UnknownRelationshipTypeError extends Error {
12
+ readonly typeId: string;
13
+ constructor(typeId: string);
14
+ }
15
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,gBAAiB,SAAQ,KAAK;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM;gBAAvC,MAAM,EAAE,MAAM,EAAW,KAAK,CAAC,EAAE,MAAM,YAAA;CAO7D;AAED,qBAAa,sBAAuB,SAAQ,KAAK;IACnC,QAAQ,CAAC,KAAK,EAAE,MAAM;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAAtC,KAAK,EAAE,MAAM,EAAW,MAAM,EAAE,MAAM;CAI5D;AAED,qBAAa,4BAA6B,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAAd,MAAM,EAAE,MAAM;CAIpC"}
package/dist/errors.js ADDED
@@ -0,0 +1,30 @@
1
+ export class InvalidEdgeError extends Error {
2
+ reason;
3
+ field;
4
+ constructor(reason, field) {
5
+ super(`[agent-relationships] invalid edge: ${reason}` +
6
+ (field ? ` (field: ${field})` : ''));
7
+ this.reason = reason;
8
+ this.field = field;
9
+ this.name = 'InvalidEdgeError';
10
+ }
11
+ }
12
+ export class UnauthorizedActorError extends Error {
13
+ actor;
14
+ action;
15
+ constructor(actor, action) {
16
+ super(`[agent-relationships] actor ${actor} not authorized for ${action}`);
17
+ this.actor = actor;
18
+ this.action = action;
19
+ this.name = 'UnauthorizedActorError';
20
+ }
21
+ }
22
+ export class UnknownRelationshipTypeError extends Error {
23
+ typeId;
24
+ constructor(typeId) {
25
+ super(`[agent-relationships] unknown relationship type ${typeId}`);
26
+ this.typeId = typeId;
27
+ this.name = 'UnknownRelationshipTypeError';
28
+ }
29
+ }
30
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACpB;IAAyB;IAA9C,YAAqB,MAAc,EAAW,KAAc;QAC1D,KAAK,CACH,uCAAuC,MAAM,EAAE;YAC7C,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CACtC,CAAC;QAJiB,WAAM,GAAN,MAAM,CAAQ;QAAW,UAAK,GAAL,KAAK,CAAS;QAK1D,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED,MAAM,OAAO,sBAAuB,SAAQ,KAAK;IAC1B;IAAwB;IAA7C,YAAqB,KAAa,EAAW,MAAc;QACzD,KAAK,CAAC,+BAA+B,KAAK,uBAAuB,MAAM,EAAE,CAAC,CAAC;QADxD,UAAK,GAAL,KAAK,CAAQ;QAAW,WAAM,GAAN,MAAM,CAAQ;QAEzD,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED,MAAM,OAAO,4BAA6B,SAAQ,KAAK;IAChC;IAArB,YAAqB,MAAc;QACjC,KAAK,CAAC,mDAAmD,MAAM,EAAE,CAAC,CAAC;QADhD,WAAM,GAAN,MAAM,CAAQ;QAEjC,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAC;IAC7C,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ export { RELATIONSHIP_TYPE, ROLE, hashRelationshipType, hashRole, } from './constants';
2
+ export { computeEdgeId } from './edge-id';
3
+ export { TYPE_SEMANTICS, type RelationshipTypeSemantics, } from './taxonomy';
4
+ export { InvalidEdgeError, UnauthorizedActorError, UnknownRelationshipTypeError, } from './errors';
5
+ export { EdgeStatus, type RelationshipType, type Role, type Edge, type ProposeEdgeInput, type ConfirmEdgeInput, type RevokeEdgeInput, type SetRolesInput, type AgentRelationshipsClientOpts, } from './types';
6
+ export { AgentRelationshipsClient, type WriteContext } from './client';
7
+ export { agentRelationshipAbi, relationshipTypeRegistryAbi, } from './abis';
8
+ export { buildProposeEdgeCall, buildConfirmEdgeCall, buildActivateEdgeCall, buildRevokeEdgeCall, buildAddRoleCall, buildRemoveRoleCall, buildSetMetadataCall, type ContractCall, } from './calls';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,iBAAiB,EACjB,IAAI,EACJ,oBAAoB,EACpB,QAAQ,GACT,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EACL,cAAc,EACd,KAAK,yBAAyB,GAC/B,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,UAAU,EACV,KAAK,gBAAgB,EACrB,KAAK,IAAI,EACT,KAAK,IAAI,EACT,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,4BAA4B,GAClC,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,wBAAwB,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAIvE,OAAO,EACL,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,QAAQ,CAAC;AAIhB,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,20 @@
1
+ // @agenticprimitives/agent-relationships — public API.
2
+ //
3
+ // See:
4
+ // - capability.manifest.json — boundary
5
+ // - CLAUDE.md — doctrine
6
+ // - specs/216-agent-relationships.md — the contract
7
+ // - docs/architecture/decisions/0007-agent-identity-stack-three-packages.md
8
+ export { RELATIONSHIP_TYPE, ROLE, hashRelationshipType, hashRole, } from './constants';
9
+ export { computeEdgeId } from './edge-id';
10
+ export { TYPE_SEMANTICS, } from './taxonomy';
11
+ export { InvalidEdgeError, UnauthorizedActorError, UnknownRelationshipTypeError, } from './errors';
12
+ export { EdgeStatus, } from './types';
13
+ export { AgentRelationshipsClient } from './client';
14
+ // Phase 3 contract ABIs (live at deployed addresses recorded in
15
+ // packages/contracts/deployments-<network>.json).
16
+ export { agentRelationshipAbi, relationshipTypeRegistryAbi, } from './abis';
17
+ // Phase 4 pure call builders. Compose into AgentAccount.execute /
18
+ // CustodyPolicy ceremonies / ERC-4337 UserOps as needed.
19
+ export { buildProposeEdgeCall, buildConfirmEdgeCall, buildActivateEdgeCall, buildRevokeEdgeCall, buildAddRoleCall, buildRemoveRoleCall, buildSetMetadataCall, } from './calls';
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,EAAE;AACF,OAAO;AACP,0CAA0C;AAC1C,2BAA2B;AAC3B,sDAAsD;AACtD,8EAA8E;AAE9E,OAAO,EACL,iBAAiB,EACjB,IAAI,EACJ,oBAAoB,EACpB,QAAQ,GACT,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EACL,cAAc,GAEf,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,4BAA4B,GAC7B,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,UAAU,GASX,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,wBAAwB,EAAqB,MAAM,UAAU,CAAC;AAEvE,gEAAgE;AAChE,kDAAkD;AAClD,OAAO,EACL,oBAAoB,EACpB,2BAA2B,GAC5B,MAAM,QAAQ,CAAC;AAEhB,kEAAkE;AAClE,yDAAyD;AACzD,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,GAErB,MAAM,SAAS,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Relationship-type taxonomy + semantics map.
3
+ *
4
+ * Subpath: `@agenticprimitives/agent-relationships/taxonomy`.
5
+ *
6
+ * Each entry describes the structural properties downstream resolvers
7
+ * need to know to traverse the edge graph correctly:
8
+ *
9
+ * - `hierarchical` — induces parent/child semantics (e.g. governance).
10
+ * - `transitive` — `(A→B) ∧ (B→C) ⇒ (A→C)` for the purposes of
11
+ * membership inference. Use with caution.
12
+ * - `symmetric` — bidirectional by definition (e.g. PARTNERSHIP);
13
+ * a single PROPOSED side activates the edge.
14
+ *
15
+ * These flags are descriptive (off-chain logic acts on them); the
16
+ * on-chain contract (Phase 3) enforces the two-side-confirmation
17
+ * rule independently for non-symmetric types.
18
+ */
19
+ import { RELATIONSHIP_TYPE, ROLE, hashRelationshipType, hashRole } from './constants';
20
+ import type { Hex } from '@agenticprimitives/types';
21
+ export { RELATIONSHIP_TYPE, ROLE, hashRelationshipType, hashRole };
22
+ export interface RelationshipTypeSemantics {
23
+ /** Canonical name (the pre-image of the bytes32 type ID). */
24
+ name: string;
25
+ /** Whether traversal induces a parent/child relationship. */
26
+ hierarchical: boolean;
27
+ /** Whether membership inference is transitive across this edge. */
28
+ transitive: boolean;
29
+ /** Whether the edge is bidirectional by definition. */
30
+ symmetric: boolean;
31
+ /** One-line documentation string. */
32
+ description: string;
33
+ }
34
+ export declare const TYPE_SEMANTICS: Readonly<Record<Hex, RelationshipTypeSemantics>>;
35
+ //# sourceMappingURL=taxonomy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taxonomy.d.ts","sourceRoot":"","sources":["../src/taxonomy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACtF,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,oBAAoB,EAAE,QAAQ,EAAE,CAAC;AAEnE,MAAM,WAAW,yBAAyB;IACxC,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,YAAY,EAAE,OAAO,CAAC;IACtB,mEAAmE;IACnE,UAAU,EAAE,OAAO,CAAC;IACpB,uDAAuD;IACvD,SAAS,EAAE,OAAO,CAAC;IACnB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,yBAAyB,CAAC,CA2C1E,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Relationship-type taxonomy + semantics map.
3
+ *
4
+ * Subpath: `@agenticprimitives/agent-relationships/taxonomy`.
5
+ *
6
+ * Each entry describes the structural properties downstream resolvers
7
+ * need to know to traverse the edge graph correctly:
8
+ *
9
+ * - `hierarchical` — induces parent/child semantics (e.g. governance).
10
+ * - `transitive` — `(A→B) ∧ (B→C) ⇒ (A→C)` for the purposes of
11
+ * membership inference. Use with caution.
12
+ * - `symmetric` — bidirectional by definition (e.g. PARTNERSHIP);
13
+ * a single PROPOSED side activates the edge.
14
+ *
15
+ * These flags are descriptive (off-chain logic acts on them); the
16
+ * on-chain contract (Phase 3) enforces the two-side-confirmation
17
+ * rule independently for non-symmetric types.
18
+ */
19
+ import { RELATIONSHIP_TYPE, ROLE, hashRelationshipType, hashRole } from './constants';
20
+ export { RELATIONSHIP_TYPE, ROLE, hashRelationshipType, hashRole };
21
+ export const TYPE_SEMANTICS = Object.freeze({
22
+ [RELATIONSHIP_TYPE.HAS_MEMBER]: {
23
+ name: 'HAS_MEMBER',
24
+ hierarchical: false,
25
+ transitive: false,
26
+ symmetric: false,
27
+ description: 'Subject is a member of object (org / DAO / collective).',
28
+ },
29
+ [RELATIONSHIP_TYPE.HAS_GOVERNANCE_OVER]: {
30
+ name: 'HAS_GOVERNANCE_OVER',
31
+ hierarchical: true,
32
+ transitive: false,
33
+ symmetric: false,
34
+ description: 'Subject has governance authority over object.',
35
+ },
36
+ [RELATIONSHIP_TYPE.VALIDATION_TRUST]: {
37
+ name: 'VALIDATION_TRUST',
38
+ hierarchical: false,
39
+ transitive: false,
40
+ symmetric: false,
41
+ description: 'Subject trusts object as a validator / verifier.',
42
+ },
43
+ [RELATIONSHIP_TYPE.PARTNERSHIP]: {
44
+ name: 'PARTNERSHIP',
45
+ hierarchical: false,
46
+ transitive: false,
47
+ symmetric: true,
48
+ description: 'Bilateral partnership / cross-recognition.',
49
+ },
50
+ [RELATIONSHIP_TYPE.OPERATES_ON_BEHALF_OF]: {
51
+ name: 'OPERATES_ON_BEHALF_OF',
52
+ hierarchical: false,
53
+ transitive: false,
54
+ symmetric: false,
55
+ description: 'Subject operates on behalf of object (delegated operational authority marker).',
56
+ },
57
+ [RELATIONSHIP_TYPE.RECOMMENDS]: {
58
+ name: 'RECOMMENDS',
59
+ hierarchical: false,
60
+ transitive: false,
61
+ symmetric: false,
62
+ description: 'Subject endorses / recommends object.',
63
+ },
64
+ });
65
+ //# sourceMappingURL=taxonomy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"taxonomy.js","sourceRoot":"","sources":["../src/taxonomy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGtF,OAAO,EAAE,iBAAiB,EAAE,IAAI,EAAE,oBAAoB,EAAE,QAAQ,EAAE,CAAC;AAenE,MAAM,CAAC,MAAM,cAAc,GAAqD,MAAM,CAAC,MAAM,CAAC;IAC5F,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE;QAC9B,IAAI,EAAE,YAAY;QAClB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,KAAK;QAChB,WAAW,EAAE,yDAAyD;KACvE;IACD,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,EAAE;QACvC,IAAI,EAAE,qBAAqB;QAC3B,YAAY,EAAE,IAAI;QAClB,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,KAAK;QAChB,WAAW,EAAE,+CAA+C;KAC7D;IACD,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,EAAE;QACpC,IAAI,EAAE,kBAAkB;QACxB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,KAAK;QAChB,WAAW,EAAE,kDAAkD;KAChE;IACD,CA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