@agenticprimitives/agent-profile 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/caip10.js ADDED
@@ -0,0 +1,56 @@
1
+ /**
2
+ * CAIP-10 chain-agnostic account identifier helpers (HCS-14 +
3
+ * ERC-8004 aligned; ADR-0008).
4
+ *
5
+ * Subpath: `@agenticprimitives/agent-profile/caip10`.
6
+ *
7
+ * Grammar (per CAIP-10):
8
+ * <namespace>:<reference>:<address>
9
+ *
10
+ * Encoder is strict (allowlist-only namespaces); decoder is permissive
11
+ * (any grammar-valid string accepted) — this is the "validate at write,
12
+ * forward-compat at read" pattern.
13
+ */
14
+ import { CAIP10_NAMESPACE_ALLOWLIST } from './constants';
15
+ import { InvalidCaip10Error } from './errors';
16
+ export { CAIP10_NAMESPACE_ALLOWLIST };
17
+ const CAIP10_GRAMMAR = /^([-a-z0-9]{3,8}):([-_a-zA-Z0-9]{1,32}):([-.%a-zA-Z0-9]{1,128})$/;
18
+ /**
19
+ * Build a CAIP-10 string. Strict on the encode side — namespace must
20
+ * be in `CAIP10_NAMESPACE_ALLOWLIST`. Address half is lowercased for
21
+ * `eip155` so callers can't smuggle two different on-chain canonical
22
+ * forms past the equality check.
23
+ */
24
+ export function buildCaip10Address(parts) {
25
+ const { namespace, reference, address } = parts;
26
+ if (!CAIP10_NAMESPACE_ALLOWLIST.has(namespace)) {
27
+ throw new InvalidCaip10Error(`${namespace}:${reference}:${address}`, `namespace "${namespace}" not in allowlist (${[...CAIP10_NAMESPACE_ALLOWLIST].join('|')})`);
28
+ }
29
+ const normalizedAddress = namespace === 'eip155' ? address.toLowerCase() : address;
30
+ const out = `${namespace}:${reference}:${normalizedAddress}`;
31
+ if (!CAIP10_GRAMMAR.test(out)) {
32
+ throw new InvalidCaip10Error(out, 'does not match CAIP-10 grammar');
33
+ }
34
+ return out;
35
+ }
36
+ /**
37
+ * Parse any grammar-valid CAIP-10 string into its parts. Permissive on
38
+ * the read side — does NOT require namespace allowlist membership
39
+ * (forward-compat: future indexers may publish namespaces we haven't
40
+ * yet added). Throws only on grammar violations.
41
+ */
42
+ export function parseCaip10(value) {
43
+ const m = CAIP10_GRAMMAR.exec(value);
44
+ if (!m) {
45
+ throw new InvalidCaip10Error(value, 'does not match CAIP-10 grammar');
46
+ }
47
+ return { namespace: m[1], reference: m[2], address: m[3] };
48
+ }
49
+ /**
50
+ * Grammar-only validity check (does NOT enforce the allowlist).
51
+ * Use `buildCaip10Address` if you need allowlist enforcement.
52
+ */
53
+ export function isValidCaip10(value) {
54
+ return CAIP10_GRAMMAR.test(value);
55
+ }
56
+ //# sourceMappingURL=caip10.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"caip10.js","sourceRoot":"","sources":["../src/caip10.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAQ9C,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAEtC,MAAM,cAAc,GAAG,kEAAkE,CAAC;AAE1F;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAkB;IACnD,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IAChD,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,kBAAkB,CAC1B,GAAG,SAAS,IAAI,SAAS,IAAI,OAAO,EAAE,EACtC,cAAc,SAAS,uBAAuB,CAAC,GAAG,0BAA0B,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAC3F,CAAC;IACJ,CAAC;IACD,MAAM,iBAAiB,GAAG,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IACnF,MAAM,GAAG,GAAG,GAAG,SAAS,IAAI,SAAS,IAAI,iBAAiB,EAAE,CAAC;IAC7D,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,kBAAkB,CAAC,GAAG,EAAE,gCAAgC,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,GAAoB,CAAC;AAC9B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACvC,MAAM,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,CAAC,CAAC,EAAE,CAAC;QACP,MAAM,IAAI,kBAAkB,CAAC,KAAK,EAAE,gCAAgC,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,CAAE,EAAE,CAAC;AAChE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,OAAO,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Pure encoded call builders for AgentProfileResolver writes
3
+ * (ID Phase 4).
4
+ *
5
+ * Subpath: `@agenticprimitives/agent-profile/calls`.
6
+ *
7
+ * Each builder returns a `ContractCall` (`{ to, value, data }`) so
8
+ * callers can submit via any path — direct walletClient.sendTransaction
9
+ * (see AgentIdentityClient), AgentAccount.execute, CustodyPolicy
10
+ * ceremony, ERC-4337 UserOp, etc.
11
+ *
12
+ * Per ADR-0007 the package boundary forbids importing agent-naming /
13
+ * agent-relationships / delegation / custody — these builders stay
14
+ * pure encode-only.
15
+ */
16
+ import type { Address, Hex } from '@agenticprimitives/types';
17
+ /** Minimal call-shape: the standard `{ to, value, data }` triple. */
18
+ export interface ContractCall {
19
+ to: Address;
20
+ value: bigint;
21
+ data: Hex;
22
+ }
23
+ /**
24
+ * Build a call to register an agent's profile for the first time.
25
+ * The walletClient's account MUST equal `agent`. Subsequent updates
26
+ * go through the typed setters / setMetadata.
27
+ */
28
+ export declare function buildRegisterProfileCall(args: {
29
+ profileResolver: Address;
30
+ agent: Address;
31
+ displayName?: string;
32
+ description?: string;
33
+ agentKind?: Hex;
34
+ profileSchemaURI?: string;
35
+ }): ContractCall;
36
+ /**
37
+ * Build a call to set / update the off-chain profile anchor
38
+ * (metadataURI + metadataHash). The walletClient's account MUST
39
+ * equal `agent` AND the agent must already be registered.
40
+ */
41
+ export declare function buildSetProfileMetadataCall(args: {
42
+ profileResolver: Address;
43
+ agent: Address;
44
+ metadataURI: string;
45
+ metadataHash: Hex;
46
+ }): ContractCall;
47
+ /** Set a single string property on an agent's profile. */
48
+ export declare function buildSetProfileStringCall(args: {
49
+ profileResolver: Address;
50
+ agent: Address;
51
+ predicate: Hex;
52
+ value: string;
53
+ }): ContractCall;
54
+ /** Set a single address property on an agent's profile. */
55
+ export declare function buildSetProfileAddressCall(args: {
56
+ profileResolver: Address;
57
+ agent: Address;
58
+ predicate: Hex;
59
+ value: Address;
60
+ }): ContractCall;
61
+ /** Set a single bytes32 property on an agent's profile. */
62
+ export declare function buildSetProfileBytes32Call(args: {
63
+ profileResolver: Address;
64
+ agent: Address;
65
+ predicate: Hex;
66
+ value: Hex;
67
+ }): ContractCall;
68
+ /** Flip the `atl:profileActive` boolean for an agent. */
69
+ export declare function buildSetProfileActiveCall(args: {
70
+ profileResolver: Address;
71
+ agent: Address;
72
+ active: boolean;
73
+ }): ContractCall;
74
+ //# sourceMappingURL=calls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calls.d.ts","sourceRoot":"","sources":["../src/calls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;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,wBAAgB,yBAAyB,CAAC,IAAI,EAAE;IAC9C,eAAe,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB,GAAG,YAAY,CAUf"}
package/dist/calls.js ADDED
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Pure encoded call builders for AgentProfileResolver writes
3
+ * (ID Phase 4).
4
+ *
5
+ * Subpath: `@agenticprimitives/agent-profile/calls`.
6
+ *
7
+ * Each builder returns a `ContractCall` (`{ to, value, data }`) so
8
+ * callers can submit via any path — direct walletClient.sendTransaction
9
+ * (see AgentIdentityClient), AgentAccount.execute, CustodyPolicy
10
+ * ceremony, ERC-4337 UserOp, etc.
11
+ *
12
+ * Per ADR-0007 the package boundary forbids importing agent-naming /
13
+ * agent-relationships / delegation / custody — these builders stay
14
+ * pure encode-only.
15
+ */
16
+ import { encodeFunctionData } from 'viem';
17
+ import { agentProfileResolverAbi } from './abis';
18
+ const ZERO_BYTES32 = '0x0000000000000000000000000000000000000000000000000000000000000000';
19
+ /**
20
+ * Build a call to register an agent's profile for the first time.
21
+ * The walletClient's account MUST equal `agent`. Subsequent updates
22
+ * go through the typed setters / setMetadata.
23
+ */
24
+ export function buildRegisterProfileCall(args) {
25
+ return {
26
+ to: args.profileResolver,
27
+ value: 0n,
28
+ data: encodeFunctionData({
29
+ abi: agentProfileResolverAbi,
30
+ functionName: 'register',
31
+ args: [
32
+ args.agent,
33
+ args.displayName ?? '',
34
+ args.description ?? '',
35
+ args.agentKind ?? ZERO_BYTES32,
36
+ args.profileSchemaURI ?? '',
37
+ ],
38
+ }),
39
+ };
40
+ }
41
+ /**
42
+ * Build a call to set / update the off-chain profile anchor
43
+ * (metadataURI + metadataHash). The walletClient's account MUST
44
+ * equal `agent` AND the agent must already be registered.
45
+ */
46
+ export function buildSetProfileMetadataCall(args) {
47
+ return {
48
+ to: args.profileResolver,
49
+ value: 0n,
50
+ data: encodeFunctionData({
51
+ abi: agentProfileResolverAbi,
52
+ functionName: 'setMetadata',
53
+ args: [args.agent, args.metadataURI, args.metadataHash],
54
+ }),
55
+ };
56
+ }
57
+ /** Set a single string property on an agent's profile. */
58
+ export function buildSetProfileStringCall(args) {
59
+ return {
60
+ to: args.profileResolver,
61
+ value: 0n,
62
+ data: encodeFunctionData({
63
+ abi: agentProfileResolverAbi,
64
+ functionName: 'setStringProperty',
65
+ args: [args.agent, args.predicate, args.value],
66
+ }),
67
+ };
68
+ }
69
+ /** Set a single address property on an agent's profile. */
70
+ export function buildSetProfileAddressCall(args) {
71
+ return {
72
+ to: args.profileResolver,
73
+ value: 0n,
74
+ data: encodeFunctionData({
75
+ abi: agentProfileResolverAbi,
76
+ functionName: 'setAddressProperty',
77
+ args: [args.agent, args.predicate, args.value],
78
+ }),
79
+ };
80
+ }
81
+ /** Set a single bytes32 property on an agent's profile. */
82
+ export function buildSetProfileBytes32Call(args) {
83
+ return {
84
+ to: args.profileResolver,
85
+ value: 0n,
86
+ data: encodeFunctionData({
87
+ abi: agentProfileResolverAbi,
88
+ functionName: 'setBytes32Property',
89
+ args: [args.agent, args.predicate, args.value],
90
+ }),
91
+ };
92
+ }
93
+ /** Flip the `atl:profileActive` boolean for an agent. */
94
+ export function buildSetProfileActiveCall(args) {
95
+ return {
96
+ to: args.profileResolver,
97
+ value: 0n,
98
+ data: encodeFunctionData({
99
+ abi: agentProfileResolverAbi,
100
+ functionName: 'setActive',
101
+ args: [args.agent, args.active],
102
+ }),
103
+ };
104
+ }
105
+ //# sourceMappingURL=calls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calls.js","sourceRoot":"","sources":["../src/calls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAC;AASjD,MAAM,YAAY,GAAG,oEAA2E,CAAC;AAEjG;;;;GAIG;AACH,MAA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,EAAE,kBAAkB,CAAC;YACvB,GAAG,EAAE,uBAAuB;YAC5B,YAAY,EAAE,oBAAoB;YAClC,IAAI,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC;SAC/C,CAAC;KACH,CAAC;AACJ,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,0BAA0B,CAAC,IAK1C;IACC,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,eAAe;QACxB,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,kBAAkB,CAAC;YACvB,GAAG,EAAE,uBAAuB;YAC5B,YAAY,EAAE,oBAAoB;YAClC,IAAI,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC;SAC/C,CAAC;KACH,CAAC;AACJ,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,yBAAyB,CAAC,IAIzC;IACC,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,eAAe;QACxB,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,kBAAkB,CAAC;YACvB,GAAG,EAAE,uBAAuB;YAC5B,YAAY,EAAE,WAAW;YACzB,IAAI,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;SAChC,CAAC;KACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,81 @@
1
+ import { type Address, type Hex, type WalletClient } from 'viem';
2
+ import type { AgentCard, AgentIdentityClientOpts, PublishProfileInput, VerificationMethod } from './types';
3
+ /**
4
+ * Optional per-call submission context. Required for write methods.
5
+ */
6
+ export interface WriteContext {
7
+ walletClient: WalletClient;
8
+ }
9
+ /**
10
+ * Read + write client for agent identity profiles.
11
+ *
12
+ * Phase 2 lands the `fetchProfile` read path against the live
13
+ * AgentProfileResolver: read `metadata-uri` + `metadata-hash`,
14
+ * HTTP-fetch the JSON, verify the canonical-JSON content-hash
15
+ * matches the on-chain anchor (anti-mutation invariant).
16
+ *
17
+ * Configuration: `opts.profileResolver` MUST be the deployed
18
+ * AgentProfileResolver contract address.
19
+ */
20
+ export interface AgentIdentityClientOptsLive extends AgentIdentityClientOpts {
21
+ profileResolver: Address;
22
+ /** Optional fetcher (test injection). Defaults to globalThis.fetch. */
23
+ fetch?: typeof fetch;
24
+ }
25
+ export declare class AgentIdentityClient {
26
+ readonly opts: AgentIdentityClientOptsLive;
27
+ private readonly publicClient;
28
+ private readonly profileResolver;
29
+ private readonly fetcher;
30
+ constructor(opts: AgentIdentityClientOptsLive);
31
+ /**
32
+ * Fetch the AgentCard for `agent`:
33
+ * 1. Read `atl:metadataURI` + `atl:metadataHash` from the
34
+ * AgentProfileResolver (on-chain anchor).
35
+ * 2. HTTP-fetch the JSON at metadataURI.
36
+ * 3. Compute `profileContentHash(parsed)` over canonical JSON.
37
+ * 4. Compare against the on-chain hash; throw on mismatch
38
+ * (anti-mutation invariant — spec 217 § 6).
39
+ *
40
+ * Returns `null` when no profile is published OR the agent has no
41
+ * `atl:metadataURI` record (treated equivalently — the on-chain
42
+ * anchor is absent).
43
+ */
44
+ fetchProfile(agent: Address): Promise<AgentCard | null>;
45
+ /**
46
+ * Verify endpoint control for an MCP server profile. Phase 2
47
+ * scope: shape-only (caller declares which method). Real
48
+ * verification (DNS TXT lookup, signed-URL recovery, HTTP
49
+ * challenge, VP signature) ships in a follow-up.
50
+ */
51
+ verifyEndpoint(agent: Address, endpoint: string, methods: VerificationMethod[]): Promise<VerificationMethod | null>;
52
+ /**
53
+ * Publish a profile by:
54
+ * 1. Validating the AgentCard + computing its canonical
55
+ * content-hash.
56
+ * 2. (If `expectedHash` set) asserting it matches our computed
57
+ * hash — anti-spoof self-check.
58
+ * 3. (If agent is not yet registered AND `registerWith` is set)
59
+ * calling AgentProfileResolver.register first.
60
+ * 4. Calling AgentProfileResolver.setMetadata(metadataURI,
61
+ * contentHash) to anchor the profile.
62
+ *
63
+ * The walletClient's account MUST equal `input.agent` — the
64
+ * contract enforces `msg.sender == agent`.
65
+ *
66
+ * Storage is OUT OF SCOPE for this SDK (per ADR-0007): the caller
67
+ * uploads the canonical JSON to `metadataURI` BEFORE calling this
68
+ * method. Use `canonicalProfileJson(input.profile)` to produce the
69
+ * exact bytes that hash to the on-chain anchor.
70
+ *
71
+ * Returns the metadata-set tx hash (the canonical "I've published"
72
+ * marker). If `register` was called, that tx is awaited first.
73
+ */
74
+ publishProfile(input: PublishProfileInput, ctx: WriteContext): Promise<Hex>;
75
+ /**
76
+ * Submit a single ContractCall via the bound walletClient. Uses
77
+ * explicit nonce fetch + retry on "replacement underpriced".
78
+ */
79
+ private _submit;
80
+ }
81
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,KAAK,OAAO,EAAE,KAAK,GAAG,EAAqB,KAAK,YAAY,EAAE,MAAM,MAAM,CAAC;AAQhI,OAAO,KAAK,EACV,SAAS,EACT,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,YAAY,EAAE,YAAY,CAAC;CAC5B;AAMD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,2BAA4B,SAAQ,uBAAuB;IAC1E,eAAe,EAAE,OAAO,CAAC;IACzB,uEAAuE;IACvE,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,qBAAa,mBAAmB;IAKlB,QAAQ,CAAC,IAAI,EAAE,2BAA2B;IAJtD,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAU;IAC1C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAe;gBAElB,IAAI,EAAE,2BAA2B;IAetD;;;;;;;;;;;;OAYG;IACG,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC;IAiC7D;;;;;OAKG;IACG,cAAc,CAClB,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,kBAAkB,EAAE,GAC5B,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAYrC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC;IAiDjF;;;OAGG;YACW,OAAO;CAiCtB"}
package/dist/client.js ADDED
@@ -0,0 +1,200 @@
1
+ import { createPublicClient, http, keccak256, toHex } from 'viem';
2
+ import { agentProfileResolverAbi } from './abis';
3
+ import { profileContentHash, canonicalProfileJson } from './profile';
4
+ import { ProfileHashMismatchError } from './errors';
5
+ import { buildRegisterProfileCall, buildSetProfileMetadataCall, } from './calls';
6
+ const ZERO_NODE = '0x0000000000000000000000000000000000000000000000000000000000000000';
7
+ const ATL_METADATA_URI = keccak256(toHex('atl:metadataURI'));
8
+ const ATL_METADATA_HASH = keccak256(toHex('atl:metadataHash'));
9
+ export class AgentIdentityClient {
10
+ opts;
11
+ publicClient;
12
+ profileResolver;
13
+ fetcher;
14
+ constructor(opts) {
15
+ this.opts = opts;
16
+ if (!opts.rpcUrl)
17
+ throw new Error('[agent-profile] rpcUrl required');
18
+ if (typeof opts.chainId !== 'number') {
19
+ throw new Error('[agent-profile] chainId required');
20
+ }
21
+ if (!opts.profileResolver) {
22
+ throw new Error('[agent-profile] profileResolver address required');
23
+ }
24
+ this.publicClient = createPublicClient({ transport: http(opts.rpcUrl) });
25
+ this.profileResolver = opts.profileResolver;
26
+ this.fetcher = opts.fetch ?? globalThis.fetch.bind(globalThis);
27
+ }
28
+ // ─── Reads (Phase 2 — live) ─────────────────────────────────────
29
+ /**
30
+ * Fetch the AgentCard for `agent`:
31
+ * 1. Read `atl:metadataURI` + `atl:metadataHash` from the
32
+ * AgentProfileResolver (on-chain anchor).
33
+ * 2. HTTP-fetch the JSON at metadataURI.
34
+ * 3. Compute `profileContentHash(parsed)` over canonical JSON.
35
+ * 4. Compare against the on-chain hash; throw on mismatch
36
+ * (anti-mutation invariant — spec 217 § 6).
37
+ *
38
+ * Returns `null` when no profile is published OR the agent has no
39
+ * `atl:metadataURI` record (treated equivalently — the on-chain
40
+ * anchor is absent).
41
+ */
42
+ async fetchProfile(agent) {
43
+ const [uri, anchorHash] = await Promise.all([
44
+ this.publicClient.readContract({
45
+ address: this.profileResolver,
46
+ abi: agentProfileResolverAbi,
47
+ functionName: 'getStringProperty',
48
+ args: [agent, ATL_METADATA_URI],
49
+ }),
50
+ this.publicClient.readContract({
51
+ address: this.profileResolver,
52
+ abi: agentProfileResolverAbi,
53
+ functionName: 'getBytes32Property',
54
+ args: [agent, ATL_METADATA_HASH],
55
+ }),
56
+ ]);
57
+ if (!uri || uri === '')
58
+ return null;
59
+ const response = await this.fetcher(uri);
60
+ if (!response.ok) {
61
+ throw new Error(`[agent-profile] failed to fetch profile JSON: HTTP ${response.status}`);
62
+ }
63
+ const body = await response.text();
64
+ const parsed = JSON.parse(body);
65
+ // Round-trip via our canonical serializer to validate shape AND
66
+ // produce the canonical content hash to compare against the anchor.
67
+ const canonical = canonicalProfileJson(parsed);
68
+ void canonical; // forces validation
69
+ const computed = profileContentHash(parsed);
70
+ if (anchorHash !== ZERO_NODE && computed !== anchorHash) {
71
+ throw new ProfileHashMismatchError(anchorHash, computed);
72
+ }
73
+ return parsed;
74
+ }
75
+ /**
76
+ * Verify endpoint control for an MCP server profile. Phase 2
77
+ * scope: shape-only (caller declares which method). Real
78
+ * verification (DNS TXT lookup, signed-URL recovery, HTTP
79
+ * challenge, VP signature) ships in a follow-up.
80
+ */
81
+ async verifyEndpoint(agent, endpoint, methods) {
82
+ void agent;
83
+ void endpoint;
84
+ void methods;
85
+ throw new Error('I Phase 2.5 — endpoint verification ships separately; ' +
86
+ 'wire DNS-TXT / signed-URL / HTTP-challenge / VP after Phase 2 lands');
87
+ }
88
+ // ─── Writes (Phase 4 — live) ─────────────────────────────────────
89
+ /**
90
+ * Publish a profile by:
91
+ * 1. Validating the AgentCard + computing its canonical
92
+ * content-hash.
93
+ * 2. (If `expectedHash` set) asserting it matches our computed
94
+ * hash — anti-spoof self-check.
95
+ * 3. (If agent is not yet registered AND `registerWith` is set)
96
+ * calling AgentProfileResolver.register first.
97
+ * 4. Calling AgentProfileResolver.setMetadata(metadataURI,
98
+ * contentHash) to anchor the profile.
99
+ *
100
+ * The walletClient's account MUST equal `input.agent` — the
101
+ * contract enforces `msg.sender == agent`.
102
+ *
103
+ * Storage is OUT OF SCOPE for this SDK (per ADR-0007): the caller
104
+ * uploads the canonical JSON to `metadataURI` BEFORE calling this
105
+ * method. Use `canonicalProfileJson(input.profile)` to produce the
106
+ * exact bytes that hash to the on-chain anchor.
107
+ *
108
+ * Returns the metadata-set tx hash (the canonical "I've published"
109
+ * marker). If `register` was called, that tx is awaited first.
110
+ */
111
+ async publishProfile(input, ctx) {
112
+ // Validate + compute hash.
113
+ canonicalProfileJson(input.profile); // throws on invalid shape
114
+ const computed = profileContentHash(input.profile);
115
+ if (input.expectedHash && input.expectedHash.toLowerCase() !== computed.toLowerCase()) {
116
+ throw new ProfileHashMismatchError(input.expectedHash, computed);
117
+ }
118
+ // Register first if needed.
119
+ const isRegistered = await this.publicClient.readContract({
120
+ address: this.profileResolver,
121
+ abi: agentProfileResolverAbi,
122
+ functionName: 'isRegistered',
123
+ args: [input.agent],
124
+ });
125
+ if (!isRegistered) {
126
+ const registerCall = buildRegisterProfileCall({
127
+ profileResolver: this.profileResolver,
128
+ agent: input.agent,
129
+ displayName: input.registerWith?.displayName,
130
+ description: input.registerWith?.description,
131
+ agentKind: input.registerWith?.agentKind,
132
+ profileSchemaURI: input.registerWith?.profileSchemaURI,
133
+ });
134
+ await this._submit(ctx, registerCall);
135
+ // Base Sepolia uses a load-balanced RPC pool; the next read
136
+ // can hit a node that hasn't yet observed our register tx.
137
+ // Poll isRegistered until true (cap at 10×2 s = 20 s) so the
138
+ // subsequent setMetadata simulation sees the new state.
139
+ for (let i = 0; i < 10; i++) {
140
+ const ok = await this.publicClient.readContract({
141
+ address: this.profileResolver,
142
+ abi: agentProfileResolverAbi,
143
+ functionName: 'isRegistered',
144
+ args: [input.agent],
145
+ });
146
+ if (ok)
147
+ break;
148
+ await new Promise((r) => setTimeout(r, 2000));
149
+ }
150
+ }
151
+ // Set the metadata anchor.
152
+ const setCall = buildSetProfileMetadataCall({
153
+ profileResolver: this.profileResolver,
154
+ agent: input.agent,
155
+ metadataURI: input.metadataURI,
156
+ metadataHash: computed,
157
+ });
158
+ return await this._submit(ctx, setCall);
159
+ }
160
+ /**
161
+ * Submit a single ContractCall via the bound walletClient. Uses
162
+ * explicit nonce fetch + retry on "replacement underpriced".
163
+ */
164
+ async _submit(ctx, call) {
165
+ const { walletClient } = ctx;
166
+ const account = walletClient.account;
167
+ if (!account)
168
+ throw new Error('[agent-profile] walletClient has no account');
169
+ let lastErr;
170
+ for (let attempt = 0; attempt < 3; attempt++) {
171
+ try {
172
+ const nonce = await this.publicClient.getTransactionCount({
173
+ address: account.address,
174
+ blockTag: 'pending',
175
+ });
176
+ const hash = await walletClient.sendTransaction({
177
+ to: call.to,
178
+ value: call.value,
179
+ data: call.data,
180
+ nonce,
181
+ account: walletClient.account,
182
+ chain: walletClient.chain ?? null,
183
+ });
184
+ await this.publicClient.waitForTransactionReceipt({ hash });
185
+ return hash;
186
+ }
187
+ catch (err) {
188
+ lastErr = err;
189
+ const msg = err.message ?? '';
190
+ if (msg.includes('replacement') || msg.includes('underpriced')) {
191
+ await new Promise((r) => setTimeout(r, 2000));
192
+ continue;
193
+ }
194
+ throw err;
195
+ }
196
+ }
197
+ throw lastErr instanceof Error ? lastErr : new Error('[agent-profile] _submit: exceeded retries');
198
+ }
199
+ }
200
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version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,MAAM,GAAG,CAAC;YACZ,CAAC;QACH,CAAC;QACD,MAAM,OAAO,YAAY,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACpG,CAAC;CACF"}
@@ -0,0 +1,30 @@
1
+ import { type Hex } from 'viem';
2
+ /**
3
+ * `authOrigin` profile predicate (spec 229 §4). A person agent declares
4
+ * **where its central auth lives** (the origin holding its ROOT credential)
5
+ * as an on-chain string property: `getStringProperty(agent, AUTH_ORIGIN)` → e.g.
6
+ * `"https://<handle>.<connect-domain>"`. The concrete domain is a deployment
7
+ * concern owned by the consuming app, never this package (see the
8
+ * "no deployment-domain code in packages" rule in the root CLAUDE.md).
9
+ *
10
+ * Relying sites resolve `name → agent → authOrigin` as a SINGLE read
11
+ * (ADR-0013, one mechanism). An UNSET facet is an *answer*, not a trigger to
12
+ * try a second lookup — it resolves to the relying site's configured platform
13
+ * default origin (a pure constant). Predicate = `keccak256("authOrigin")`.
14
+ */
15
+ export declare const AUTH_ORIGIN: Hex;
16
+ /**
17
+ * Phase 1 CAIP-10 namespace allowlist. Per ADR-0008 the encoder is
18
+ * strict (validate-at-write); the decoder is permissive
19
+ * (forward-compatible). Expand this list when a concrete consumer
20
+ * needs cross-resolver interop with a new chain family — PR + golden
21
+ * vector test required.
22
+ */
23
+ export declare const CAIP10_NAMESPACE_ALLOWLIST: ReadonlySet<string>;
24
+ /**
25
+ * AgentCard schema version. Bump on any breaking change to the typed
26
+ * profile shape; canonical-JSON content-hash incorporates this field
27
+ * so old + new profiles never collide.
28
+ */
29
+ export declare const AGENT_CARD_SCHEMA_VERSION: 1;
30
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAElD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,WAAW,EAAE,GAAoC,CAAC;AAE/D;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,EAAE,WAAW,CAAC,MAAM,CAIzD,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAG,CAAU,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { keccak256, toHex } from 'viem';
2
+ /**
3
+ * `authOrigin` profile predicate (spec 229 §4). A person agent declares
4
+ * **where its central auth lives** (the origin holding its ROOT credential)
5
+ * as an on-chain string property: `getStringProperty(agent, AUTH_ORIGIN)` → e.g.
6
+ * `"https://<handle>.<connect-domain>"`. The concrete domain is a deployment
7
+ * concern owned by the consuming app, never this package (see the
8
+ * "no deployment-domain code in packages" rule in the root CLAUDE.md).
9
+ *
10
+ * Relying sites resolve `name → agent → authOrigin` as a SINGLE read
11
+ * (ADR-0013, one mechanism). An UNSET facet is an *answer*, not a trigger to
12
+ * try a second lookup — it resolves to the relying site's configured platform
13
+ * default origin (a pure constant). Predicate = `keccak256("authOrigin")`.
14
+ */
15
+ export const AUTH_ORIGIN = keccak256(toHex('authOrigin'));
16
+ /**
17
+ * Phase 1 CAIP-10 namespace allowlist. Per ADR-0008 the encoder is
18
+ * strict (validate-at-write); the decoder is permissive
19
+ * (forward-compatible). Expand this list when a concrete consumer
20
+ * needs cross-resolver interop with a new chain family — PR + golden
21
+ * vector test required.
22
+ */
23
+ export const CAIP10_NAMESPACE_ALLOWLIST = new Set([
24
+ 'eip155', // EVM chains
25
+ 'hedera', // Hedera Hashgraph
26
+ 'solana', // Solana
27
+ ]);
28
+ /**
29
+ * AgentCard schema version. Bump on any breaking change to the typed
30
+ * profile shape; canonical-JSON content-hash incorporates this field
31
+ * so old + new profiles never collide.
32
+ */
33
+ export const AGENT_CARD_SCHEMA_VERSION = 1;
34
+ //# 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,EAAY,MAAM,MAAM,CAAC;AAElD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,WAAW,GAAQ,SAAS,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAwB,IAAI,GAAG,CAAC;IACrE,QAAQ,EAAE,aAAa;IACvB,QAAQ,EAAE,mBAAmB;IAC7B,QAAQ,EAAE,SAAS;CACpB,CAAC,CAAC;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAU,CAAC"}
@@ -0,0 +1,22 @@
1
+ export declare class InvalidProfileError extends Error {
2
+ readonly reason: string;
3
+ readonly field?: string | undefined;
4
+ constructor(reason: string, field?: string | undefined);
5
+ }
6
+ export declare class ProfileHashMismatchError extends Error {
7
+ readonly expected: string;
8
+ readonly actual: string;
9
+ constructor(expected: string, actual: string);
10
+ }
11
+ export declare class EndpointVerificationError extends Error {
12
+ readonly method: string;
13
+ readonly endpoint: string;
14
+ readonly reason: string;
15
+ constructor(method: string, endpoint: string, reason: string);
16
+ }
17
+ export declare class InvalidCaip10Error extends Error {
18
+ readonly value: string;
19
+ readonly reason: string;
20
+ constructor(value: string, reason: string);
21
+ }
22
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,mBAAoB,SAAQ,KAAK;IAChC,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,wBAAyB,SAAQ,KAAK;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAAzC,QAAQ,EAAE,MAAM,EAAW,MAAM,EAAE,MAAM;CAM/D;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAAlE,MAAM,EAAE,MAAM,EAAW,QAAQ,EAAE,MAAM,EAAW,MAAM,EAAE,MAAM;CAIxF;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM;gBAAtC,KAAK,EAAE,MAAM,EAAW,MAAM,EAAE,MAAM;CAI5D"}