@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/LICENSE +21 -0
- package/README.md +113 -0
- package/dist/abis.d.ts +336 -0
- package/dist/abis.d.ts.map +1 -0
- package/dist/abis.js +98 -0
- package/dist/abis.js.map +1 -0
- package/dist/caip10.d.ts +37 -0
- package/dist/caip10.d.ts.map +1 -0
- package/dist/caip10.js +56 -0
- package/dist/caip10.js.map +1 -0
- package/dist/calls.d.ts +74 -0
- package/dist/calls.d.ts.map +1 -0
- package/dist/calls.js +105 -0
- package/dist/calls.js.map +1 -0
- package/dist/client.d.ts +81 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +200 -0
- package/dist/client.js.map +1 -0
- package/dist/constants.d.ts +30 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +34 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors.d.ts +22 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +44 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/profile.d.ts +25 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +101 -0
- package/dist/profile.js.map +1 -0
- package/dist/types.d.ts +102 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +67 -0
- package/spec.md +12 -0
package/dist/errors.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export class InvalidProfileError extends Error {
|
|
2
|
+
reason;
|
|
3
|
+
field;
|
|
4
|
+
constructor(reason, field) {
|
|
5
|
+
super(`[agent-profile] invalid profile: ${reason}` +
|
|
6
|
+
(field ? ` (field: ${field})` : ''));
|
|
7
|
+
this.reason = reason;
|
|
8
|
+
this.field = field;
|
|
9
|
+
this.name = 'InvalidProfileError';
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class ProfileHashMismatchError extends Error {
|
|
13
|
+
expected;
|
|
14
|
+
actual;
|
|
15
|
+
constructor(expected, actual) {
|
|
16
|
+
super(`[agent-profile] profile content-hash mismatch — on-chain ${expected} vs computed ${actual}`);
|
|
17
|
+
this.expected = expected;
|
|
18
|
+
this.actual = actual;
|
|
19
|
+
this.name = 'ProfileHashMismatchError';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export class EndpointVerificationError extends Error {
|
|
23
|
+
method;
|
|
24
|
+
endpoint;
|
|
25
|
+
reason;
|
|
26
|
+
constructor(method, endpoint, reason) {
|
|
27
|
+
super(`[agent-profile] ${method} verification failed for ${endpoint}: ${reason}`);
|
|
28
|
+
this.method = method;
|
|
29
|
+
this.endpoint = endpoint;
|
|
30
|
+
this.reason = reason;
|
|
31
|
+
this.name = 'EndpointVerificationError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export class InvalidCaip10Error extends Error {
|
|
35
|
+
value;
|
|
36
|
+
reason;
|
|
37
|
+
constructor(value, reason) {
|
|
38
|
+
super(`[agent-profile] invalid CAIP-10 "${value}": ${reason}`);
|
|
39
|
+
this.value = value;
|
|
40
|
+
this.reason = reason;
|
|
41
|
+
this.name = 'InvalidCaip10Error';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,mBAAoB,SAAQ,KAAK;IACvB;IAAyB;IAA9C,YAAqB,MAAc,EAAW,KAAc;QAC1D,KAAK,CACH,oCAAoC,MAAM,EAAE;YAC1C,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,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED,MAAM,OAAO,wBAAyB,SAAQ,KAAK;IAC5B;IAA2B;IAAhD,YAAqB,QAAgB,EAAW,MAAc;QAC5D,KAAK,CACH,4DAA4D,QAAQ,gBAAgB,MAAM,EAAE,CAC7F,CAAC;QAHiB,aAAQ,GAAR,QAAQ,CAAQ;QAAW,WAAM,GAAN,MAAM,CAAQ;QAI5D,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;IACzC,CAAC;CACF;AAED,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAC7B;IAAyB;IAA2B;IAAzE,YAAqB,MAAc,EAAW,QAAgB,EAAW,MAAc;QACrF,KAAK,CAAC,mBAAmB,MAAM,4BAA4B,QAAQ,KAAK,MAAM,EAAE,CAAC,CAAC;QAD/D,WAAM,GAAN,MAAM,CAAQ;QAAW,aAAQ,GAAR,QAAQ,CAAQ;QAAW,WAAM,GAAN,MAAM,CAAQ;QAErF,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACtB;IAAwB;IAA7C,YAAqB,KAAa,EAAW,MAAc;QACzD,KAAK,CAAC,oCAAoC,KAAK,MAAM,MAAM,EAAE,CAAC,CAAC;QAD5C,UAAK,GAAL,KAAK,CAAQ;QAAW,WAAM,GAAN,MAAM,CAAQ;QAEzD,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { CAIP10_NAMESPACE_ALLOWLIST, AGENT_CARD_SCHEMA_VERSION, AUTH_ORIGIN, } from './constants';
|
|
2
|
+
export { buildCaip10Address, parseCaip10, isValidCaip10, type Caip10Parts, } from './caip10';
|
|
3
|
+
export { canonicalProfileJson, profileContentHash, } from './profile';
|
|
4
|
+
export { InvalidProfileError, ProfileHashMismatchError, EndpointVerificationError, InvalidCaip10Error, } from './errors';
|
|
5
|
+
export type { ProfileType, Caip10Address, VerificationMethod, AiAgentProfile, McpServerProfile, MultisigProfile, ServiceProfile, AgentCard, AgentIdentityClientOpts, PublishProfileInput, } from './types';
|
|
6
|
+
export { AgentIdentityClient, type WriteContext } from './client';
|
|
7
|
+
export { agentProfileResolverAbi } from './abis';
|
|
8
|
+
export { buildRegisterProfileCall, buildSetProfileMetadataCall, buildSetProfileStringCall, buildSetProfileAddressCall, buildSetProfileBytes32Call, buildSetProfileActiveCall, 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":"AASA,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,KAAK,WAAW,GACjB,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAElB,YAAY,EACV,WAAW,EACX,aAAa,EACb,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,SAAS,EACT,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,mBAAmB,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAMlE,OAAO,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAC;AAIjD,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,KAAK,YAAY,GAClB,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @agenticprimitives/agent-profile — public API.
|
|
2
|
+
//
|
|
3
|
+
// See:
|
|
4
|
+
// - capability.manifest.json — boundary
|
|
5
|
+
// - CLAUDE.md — doctrine
|
|
6
|
+
// - specs/217-agent-profile.md — the contract
|
|
7
|
+
// - docs/architecture/decisions/0007-agent-identity-stack-three-packages.md
|
|
8
|
+
// - docs/architecture/decisions/0008-caip10-nativeid-record-predicate.md
|
|
9
|
+
export { CAIP10_NAMESPACE_ALLOWLIST, AGENT_CARD_SCHEMA_VERSION, AUTH_ORIGIN, } from './constants';
|
|
10
|
+
export { buildCaip10Address, parseCaip10, isValidCaip10, } from './caip10';
|
|
11
|
+
export { canonicalProfileJson, profileContentHash, } from './profile';
|
|
12
|
+
export { InvalidProfileError, ProfileHashMismatchError, EndpointVerificationError, InvalidCaip10Error, } from './errors';
|
|
13
|
+
export { AgentIdentityClient } from './client';
|
|
14
|
+
// Phase 3 contract ABIs (live at deployed addresses recorded in
|
|
15
|
+
// packages/contracts/deployments-<network>.json). Profile resolver
|
|
16
|
+
// inherits AttributeStorage; predicates governed by the shared
|
|
17
|
+
// OntologyTermRegistry from agent-naming.
|
|
18
|
+
export { agentProfileResolverAbi } from './abis';
|
|
19
|
+
// Phase 4 pure call builders. Compose into AgentAccount.execute /
|
|
20
|
+
// CustodyPolicy ceremonies / ERC-4337 UserOps as needed.
|
|
21
|
+
export { buildRegisterProfileCall, buildSetProfileMetadataCall, buildSetProfileStringCall, buildSetProfileAddressCall, buildSetProfileBytes32Call, buildSetProfileActiveCall, } from './calls';
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,EAAE;AACF,OAAO;AACP,0CAA0C;AAC1C,2BAA2B;AAC3B,gDAAgD;AAChD,8EAA8E;AAC9E,2EAA2E;AAE3E,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,WAAW,GACZ,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,aAAa,GAEd,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,oBAAoB,EACpB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAelB,OAAO,EAAE,mBAAmB,EAAqB,MAAM,UAAU,CAAC;AAElE,gEAAgE;AAChE,mEAAmE;AACnE,+DAA+D;AAC/D,0CAA0C;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAC;AAEjD,kEAAkE;AAClE,yDAAyD;AACzD,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,yBAAyB,EACzB,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,GAE1B,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical-JSON serialization + content-hash for AgentCard profiles.
|
|
3
|
+
*
|
|
4
|
+
* Subpath: `@agenticprimitives/agent-profile/profile`.
|
|
5
|
+
*
|
|
6
|
+
* The hash is used as the on-chain `metadata-hash` record predicate
|
|
7
|
+
* in agent-naming. Two semantically-equal profiles MUST produce the
|
|
8
|
+
* same hash — sort keys, fixed numeric format, no whitespace.
|
|
9
|
+
*/
|
|
10
|
+
import type { AgentCard } from './types';
|
|
11
|
+
/**
|
|
12
|
+
* Canonical-JSON encoding. Sorts object keys recursively, omits
|
|
13
|
+
* `undefined`, refuses non-finite numbers, refuses functions.
|
|
14
|
+
*
|
|
15
|
+
* Note: `JSON.stringify` does NOT sort keys, so we do it manually.
|
|
16
|
+
* Arrays preserve insertion order (semantically meaningful).
|
|
17
|
+
*/
|
|
18
|
+
export declare function canonicalProfileJson(profile: AgentCard): string;
|
|
19
|
+
/**
|
|
20
|
+
* Keccak-256 of the canonical-JSON encoding of a profile. Matches
|
|
21
|
+
* the `metadata-hash` predicate in `agent-naming/records`. Stable
|
|
22
|
+
* across runtimes — UTF-8 byte-level deterministic.
|
|
23
|
+
*/
|
|
24
|
+
export declare function profileContentHash(profile: AgentCard): `0x${string}`;
|
|
25
|
+
//# sourceMappingURL=profile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,SAAS,GAAG,MAAM,CAI/D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,SAAS,GAAG,KAAK,MAAM,EAAE,CAGpE"}
|
package/dist/profile.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical-JSON serialization + content-hash for AgentCard profiles.
|
|
3
|
+
*
|
|
4
|
+
* Subpath: `@agenticprimitives/agent-profile/profile`.
|
|
5
|
+
*
|
|
6
|
+
* The hash is used as the on-chain `metadata-hash` record predicate
|
|
7
|
+
* in agent-naming. Two semantically-equal profiles MUST produce the
|
|
8
|
+
* same hash — sort keys, fixed numeric format, no whitespace.
|
|
9
|
+
*/
|
|
10
|
+
import { keccak256, toHex } from 'viem';
|
|
11
|
+
import { AGENT_CARD_SCHEMA_VERSION } from './constants';
|
|
12
|
+
import { InvalidProfileError } from './errors';
|
|
13
|
+
/**
|
|
14
|
+
* Canonical-JSON encoding. Sorts object keys recursively, omits
|
|
15
|
+
* `undefined`, refuses non-finite numbers, refuses functions.
|
|
16
|
+
*
|
|
17
|
+
* Note: `JSON.stringify` does NOT sort keys, so we do it manually.
|
|
18
|
+
* Arrays preserve insertion order (semantically meaningful).
|
|
19
|
+
*/
|
|
20
|
+
export function canonicalProfileJson(profile) {
|
|
21
|
+
validateProfile(profile);
|
|
22
|
+
const withVersion = { ...profile, schemaVersion: AGENT_CARD_SCHEMA_VERSION };
|
|
23
|
+
return canonicalJsonStringify(withVersion);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Keccak-256 of the canonical-JSON encoding of a profile. Matches
|
|
27
|
+
* the `metadata-hash` predicate in `agent-naming/records`. Stable
|
|
28
|
+
* across runtimes — UTF-8 byte-level deterministic.
|
|
29
|
+
*/
|
|
30
|
+
export function profileContentHash(profile) {
|
|
31
|
+
const json = canonicalProfileJson(profile);
|
|
32
|
+
return keccak256(toHex(json));
|
|
33
|
+
}
|
|
34
|
+
// ─── Internal ───────────────────────────────────────────────────────
|
|
35
|
+
function validateProfile(profile) {
|
|
36
|
+
if (!profile || typeof profile !== 'object') {
|
|
37
|
+
throw new InvalidProfileError('profile must be an object');
|
|
38
|
+
}
|
|
39
|
+
if (typeof profile.type !== 'string') {
|
|
40
|
+
throw new InvalidProfileError('profile.type is required', 'type');
|
|
41
|
+
}
|
|
42
|
+
switch (profile.type) {
|
|
43
|
+
case 'person':
|
|
44
|
+
case 'org':
|
|
45
|
+
case 'service':
|
|
46
|
+
case 'treasury':
|
|
47
|
+
case 'mcpServer':
|
|
48
|
+
case 'multisig':
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
throw new InvalidProfileError(`unknown profile.type "${profile.type}"`, 'type');
|
|
52
|
+
}
|
|
53
|
+
if (profile.type === 'mcpServer') {
|
|
54
|
+
if (typeof profile.endpoint !== 'string' || profile.endpoint.length === 0) {
|
|
55
|
+
throw new InvalidProfileError('mcpServer profile requires endpoint', 'endpoint');
|
|
56
|
+
}
|
|
57
|
+
if (!Array.isArray(profile.verification) || profile.verification.length === 0) {
|
|
58
|
+
throw new InvalidProfileError('mcpServer profile requires at least one verification method', 'verification');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (profile.type === 'multisig') {
|
|
62
|
+
if (!Array.isArray(profile.members) || profile.members.length === 0) {
|
|
63
|
+
throw new InvalidProfileError('multisig profile requires at least one member', 'members');
|
|
64
|
+
}
|
|
65
|
+
if (typeof profile.threshold !== 'number' || profile.threshold < 1 || profile.threshold > profile.members.length) {
|
|
66
|
+
throw new InvalidProfileError(`multisig threshold must be in [1, members.length] (got ${profile.threshold})`, 'threshold');
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function canonicalJsonStringify(value) {
|
|
71
|
+
if (value === null)
|
|
72
|
+
return 'null';
|
|
73
|
+
if (typeof value === 'boolean')
|
|
74
|
+
return value ? 'true' : 'false';
|
|
75
|
+
if (typeof value === 'number') {
|
|
76
|
+
if (!Number.isFinite(value)) {
|
|
77
|
+
throw new InvalidProfileError(`non-finite number ${value} not allowed in canonical JSON`);
|
|
78
|
+
}
|
|
79
|
+
return JSON.stringify(value);
|
|
80
|
+
}
|
|
81
|
+
if (typeof value === 'string')
|
|
82
|
+
return JSON.stringify(value);
|
|
83
|
+
if (typeof value === 'function' || typeof value === 'symbol' || typeof value === 'undefined') {
|
|
84
|
+
throw new InvalidProfileError(`value of type ${typeof value} not allowed in canonical JSON`);
|
|
85
|
+
}
|
|
86
|
+
if (Array.isArray(value)) {
|
|
87
|
+
return '[' + value.map(canonicalJsonStringify).join(',') + ']';
|
|
88
|
+
}
|
|
89
|
+
if (typeof value === 'object') {
|
|
90
|
+
const entries = Object.entries(value)
|
|
91
|
+
.filter(([, v]) => v !== undefined)
|
|
92
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
|
|
93
|
+
return ('{' +
|
|
94
|
+
entries
|
|
95
|
+
.map(([k, v]) => JSON.stringify(k) + ':' + canonicalJsonStringify(v))
|
|
96
|
+
.join(',') +
|
|
97
|
+
'}');
|
|
98
|
+
}
|
|
99
|
+
throw new InvalidProfileError(`unsupported value of type ${typeof value}`);
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=profile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../src/profile.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACxC,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAAkB;IACrD,eAAe,CAAC,OAAO,CAAC,CAAC;IACzB,MAAM,WAAW,GAAG,EAAE,GAAG,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,CAAC;IAC7E,OAAO,sBAAsB,CAAC,WAAW,CAAC,CAAC;AAC7C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAkB;IACnD,MAAM,IAAI,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IAC3C,OAAO,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AAChC,CAAC;AAED,uEAAuE;AAEvE,SAAS,eAAe,CAAC,OAAkB;IACzC,IAAI,CAAC,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAC5C,MAAM,IAAI,mBAAmB,CAAC,2BAA2B,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACrC,MAAM,IAAI,mBAAmB,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC;IACpE,CAAC;IACD,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,QAAQ,CAAC;QACd,KAAK,KAAK,CAAC;QACX,KAAK,SAAS,C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AAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACpD,OAAO,CACL,GAAG;YACH,OAAO;iBACJ,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC;iBACpE,IAAI,CAAC,GAAG,CAAC;YACZ,GAAG,CACJ,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,mBAAmB,CAAC,6BAA6B,OAAO,KAAK,EAAE,CAAC,CAAC;AAC7E,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { Address, Hex, Caip10Address } from '@agenticprimitives/types';
|
|
2
|
+
export type { Caip10Address };
|
|
3
|
+
/**
|
|
4
|
+
* Discriminator for AgentCard sub-shapes. Mirrors HCS-11 § typed-profile
|
|
5
|
+
* categories with two additions specific to our model:
|
|
6
|
+
* - `treasury` (custody-policy-governed asset account)
|
|
7
|
+
* - `multisig` (collective Smart Agent with named members)
|
|
8
|
+
*
|
|
9
|
+
* Adding a new ProfileType requires: (a) a new sub-interface here,
|
|
10
|
+
* (b) handling in `canonicalProfileJson`, (c) a golden vector test
|
|
11
|
+
* in `test/profile.test.ts`.
|
|
12
|
+
*/
|
|
13
|
+
export type ProfileType = 'person' | 'org' | 'service' | 'treasury' | 'mcpServer' | 'multisig';
|
|
14
|
+
/**
|
|
15
|
+
* Endpoint-control verification methods (matches GoDaddy ANS
|
|
16
|
+
* `mcpServer.verification` pattern; we don't import their PKI).
|
|
17
|
+
*
|
|
18
|
+
* - `dns-txt` — owner publishes a TXT record at a known label;
|
|
19
|
+
* resolver fetches and matches against the on-chain digest.
|
|
20
|
+
* - `signed-url` — endpoint URL signed by the owner Smart Agent's
|
|
21
|
+
* ERC-1271 key.
|
|
22
|
+
* - `http-challenge` — well-known path returns a value derived
|
|
23
|
+
* from the agent address.
|
|
24
|
+
* - `verifiable-presentation` — W3C VP signed by the owner.
|
|
25
|
+
*/
|
|
26
|
+
export type VerificationMethod = 'dns-txt' | 'signed-url' | 'http-challenge' | 'verifiable-presentation';
|
|
27
|
+
/** Common fields across all profile sub-shapes. */
|
|
28
|
+
interface BaseProfile {
|
|
29
|
+
/** Human-friendly display name (may differ from agent-naming `displayName`). */
|
|
30
|
+
displayName?: string;
|
|
31
|
+
/** Free-text description. */
|
|
32
|
+
description?: string;
|
|
33
|
+
/** External profile / brand URL. */
|
|
34
|
+
homepage?: string;
|
|
35
|
+
/** Optional CAIP-10 chain-agnostic identifier (ADR-0008). */
|
|
36
|
+
nativeId?: Caip10Address;
|
|
37
|
+
/** Optional avatar / logo URL. */
|
|
38
|
+
avatar?: string;
|
|
39
|
+
}
|
|
40
|
+
export interface AiAgentProfile extends BaseProfile {
|
|
41
|
+
type: 'person' | 'org';
|
|
42
|
+
/** For `org`: list of member Smart Agent addresses (informational only — authority lives in agent-relationships edges). */
|
|
43
|
+
members?: Address[];
|
|
44
|
+
}
|
|
45
|
+
export interface McpServerProfile extends BaseProfile {
|
|
46
|
+
type: 'mcpServer';
|
|
47
|
+
/** Canonical MCP endpoint URL. */
|
|
48
|
+
endpoint: string;
|
|
49
|
+
/** Verification methods the owner publishes for this endpoint. */
|
|
50
|
+
verification: VerificationMethod[];
|
|
51
|
+
/** Optional list of tool names the server exposes (for discovery UIs). */
|
|
52
|
+
tools?: string[];
|
|
53
|
+
}
|
|
54
|
+
export interface MultisigProfile extends BaseProfile {
|
|
55
|
+
type: 'multisig';
|
|
56
|
+
/** Threshold for the collective Smart Agent's CustodyPolicy. */
|
|
57
|
+
threshold: number;
|
|
58
|
+
/** Named members — each member's Smart Agent address. */
|
|
59
|
+
members: Address[];
|
|
60
|
+
}
|
|
61
|
+
export interface ServiceProfile extends BaseProfile {
|
|
62
|
+
type: 'service' | 'treasury';
|
|
63
|
+
/** Canonical service endpoint (A2A / MCP / HTTP). */
|
|
64
|
+
endpoint?: string;
|
|
65
|
+
}
|
|
66
|
+
export type AgentCard = AiAgentProfile | McpServerProfile | MultisigProfile | ServiceProfile;
|
|
67
|
+
export interface AgentIdentityClientOpts {
|
|
68
|
+
rpcUrl: string;
|
|
69
|
+
chainId: number;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Input to `AgentIdentityClient.publishProfile`. The client computes
|
|
73
|
+
* `profileContentHash` from `profile` and asserts it matches the
|
|
74
|
+
* caller-supplied `expectedHash` (anti-mutation invariant).
|
|
75
|
+
*/
|
|
76
|
+
export interface PublishProfileInput {
|
|
77
|
+
/** Smart Agent address publishing the profile. */
|
|
78
|
+
agent: Address;
|
|
79
|
+
/** Profile JSON to publish. The SDK computes its canonical content-hash. */
|
|
80
|
+
profile: AgentCard;
|
|
81
|
+
/**
|
|
82
|
+
* URI where the canonical-JSON profile is hosted. The caller is
|
|
83
|
+
* responsible for uploading the JSON to this URI BEFORE calling
|
|
84
|
+
* publishProfile — storage is intentionally out of the SDK's scope
|
|
85
|
+
* (per ADR-0007: identity stack stays storage-agnostic).
|
|
86
|
+
*/
|
|
87
|
+
metadataURI: string;
|
|
88
|
+
/** Optional caller-computed hash for self-check (asserted == computed). */
|
|
89
|
+
expectedHash?: Hex;
|
|
90
|
+
/**
|
|
91
|
+
* For first-time publication only — registers the agent's profile
|
|
92
|
+
* with these initial fields before setting the metadata anchor.
|
|
93
|
+
* Omit (or pass {}) once the agent has already called `register`.
|
|
94
|
+
*/
|
|
95
|
+
registerWith?: {
|
|
96
|
+
displayName?: string;
|
|
97
|
+
description?: string;
|
|
98
|
+
agentKind?: Hex;
|
|
99
|
+
profileSchemaURI?: string;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts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AW;IACjD,IAAI,EAAE,SAAS,GAAG,UAAU,CAAC;IAC7B,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,gBAAgB,GAAG,eAAe,GAAG,cAAc,CAAC;AAE7F,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,kDAAkD;IAClD,KAAK,EAAE,OAAO,CAAC;IACf,4EAA4E;IAC5E,OAAO,EAAE,SAAS,CAAC;IACnB;;;;;OAKG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,2EAA2E;IAC3E,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB;;;;OAIG;IACH,YAAY,CAAC,EAAE;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,SAAS,CAAC,EAAE,GAAG,CAAC;QAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agenticprimitives/agent-profile",
|
|
3
|
+
"version": "0.1.0-alpha.2",
|
|
4
|
+
"description": "Agent identity SDK: HCS-11-aligned typed profile schema (AgentCard), HCS-14 CAIP-10 nativeId helpers, mcpServer.verification methods (DNS TXT / signed URL / HTTP challenge / VP), canonical-JSON content-hash. Speaks identity-domain vocabulary only.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/agentictrustlabs/agenticprimitives.git",
|
|
9
|
+
"directory": "packages/agent-profile"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/agentictrustlabs/agenticprimitives/tree/master/packages/agent-profile",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/agentictrustlabs/agenticprimitives/issues"
|
|
14
|
+
},
|
|
15
|
+
"type": "module",
|
|
16
|
+
"main": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./caip10": {
|
|
24
|
+
"types": "./dist/caip10.d.ts",
|
|
25
|
+
"import": "./dist/caip10.js"
|
|
26
|
+
},
|
|
27
|
+
"./profile": {
|
|
28
|
+
"types": "./dist/profile.d.ts",
|
|
29
|
+
"import": "./dist/profile.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"LICENSE",
|
|
34
|
+
"dist",
|
|
35
|
+
"spec.md",
|
|
36
|
+
"README.md"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsc -p tsconfig.build.json",
|
|
40
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
41
|
+
"test": "vitest run",
|
|
42
|
+
"test:watch": "vitest",
|
|
43
|
+
"clean": "rm -rf dist"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"peerDependencies": {
|
|
49
|
+
"@agenticprimitives/agent-account": "workspace:*",
|
|
50
|
+
"@agenticprimitives/connect-auth": "workspace:*",
|
|
51
|
+
"@agenticprimitives/types": "workspace:*",
|
|
52
|
+
"viem": "^2.50.0"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/node": "^22.7.0",
|
|
56
|
+
"vitest": "^2.1.0"
|
|
57
|
+
},
|
|
58
|
+
"keywords": [
|
|
59
|
+
"agent",
|
|
60
|
+
"identity",
|
|
61
|
+
"hcs-11",
|
|
62
|
+
"hcs-14",
|
|
63
|
+
"erc-8004",
|
|
64
|
+
"caip-10",
|
|
65
|
+
"agentic"
|
|
66
|
+
]
|
|
67
|
+
}
|
package/spec.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# @agenticprimitives/agent-profile — spec
|
|
2
|
+
|
|
3
|
+
The full design lives in [`../../specs/217-agent-profile.md`](../../specs/217-agent-profile.md).
|
|
4
|
+
|
|
5
|
+
Architecture decisions:
|
|
6
|
+
|
|
7
|
+
- [ADR-0007](../../docs/architecture/decisions/0007-agent-identity-stack-three-packages.md)
|
|
8
|
+
— why the identity stack is three packages, not one.
|
|
9
|
+
- [ADR-0008](../../docs/architecture/decisions/0008-caip10-nativeid-record-predicate.md)
|
|
10
|
+
— why we expose CAIP-10 `nativeId` rather than generate UAIDs.
|
|
11
|
+
|
|
12
|
+
Do not edit a divergent copy here — edit the canonical spec.
|