@agenticprimitives/related-agents 0.0.0-alpha.3

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Agentic Trust Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # @agenticprimitives/related-agents
2
+
3
+ **Some relationships are nobody else's business.** When a person creates an organization through a relying app, that person↔org link is among the most sensitive facts in the whole identity stack — and the default in most systems is to leak it: into an app database, into a public graph, into an index. This package makes the private path the only path. A person↔org link is a **private, holder-resident vault credential** — never an on-chain relationship, never relying-app-local person→org state ([ADR-0025](../../docs/architecture/decisions/0025-related-agent-links-are-private.md)). The public trust graph stays org↔org, and only on explicit bilateral consent.
4
+
5
+ Part of [agenticprimitives](../../README.md) — the trust substrate for the agent economy: one canonical Smart Agent identity with custody, delegation, naming, credentials, and audit evidence designed as one system.
6
+
7
+ It ships three things: the credential builder that links a person to a **related agent** (e.g. an org they created via a relying app), the scoped-delegation read caveats a grantee receives, and the list-query wire shapes the session broker serves — shapes that deliberately carry **no person id**, so even the listing surface cannot leak the link.
8
+
9
+ Composes [`verifiable-credentials`](../verifiable-credentials) (DOLCE+DnS Situation + EIP-712 proof) and [`delegation`](../delegation) (caveats). Sibling of [`agent-relationships`](../agent-relationships), which owns *public, on-chain* edges only — the two are firewalled by design: this package may not import that one, and person↔org is never written as an edge.
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { buildRelatedAgentCredential, relatedAgentReadCaveats } from '@agenticprimitives/related-agents';
15
+ import { signCredential } from '@agenticprimitives/verifiable-credentials';
16
+
17
+ // The broker mints this during org-create, signed by the person's ROOT credential:
18
+ const unsigned = buildRelatedAgentCredential({
19
+ holder: personSA, relatedAgent: orgSA,
20
+ purpose: 'adopter-org', requestedBy: 'relying-app',
21
+ issuerCaip10: `eip155:84532:${personSA}`,
22
+ body: { agentName: 'acme-co.agent' },
23
+ validFrom: new Date().toISOString(),
24
+ });
25
+ const credential = await signCredential(unsigned, personRootSigner);
26
+
27
+ // The scoped org→grantee delegation caveats:
28
+ const caveats = relatedAgentReadCaveats({
29
+ enforcers: { timestamp, value, allowedTargets },
30
+ validUntil, allowedTargets: [orgSA],
31
+ });
32
+ ```
33
+
34
+ The credential is self-issued (holder = issuer = the person's Smart Agent), `visibility = private`, holder-resident. The caveat set a grantee receives is time-bound, zero-value, and target-scoped — the grantee can *read* the org, not move anything. `purpose` is a free string supplied by the app; this package carries no vertical vocabulary.
35
+
36
+ ## How it's different
37
+
38
+ The competing pattern is **app-local membership tables and public social graphs** — either the relying app owns the person→org row (and the user cannot take it elsewhere or revoke the app's knowledge of it), or the link is published to a graph anyone can crawl:
39
+
40
+ - **Holder-resident, not app-resident.** The credential lives in the person's vault; the relying app gets a scoped, revocable, time-bound delegation — never the link itself.
41
+ - **Privacy is structural, not a setting.** There is no "public" flag on a person↔org link. The on-chain graph (`agent-relationships`) is reserved for org↔org edges with explicit bilateral consent.
42
+ - **Anchored to canonical identities.** Both ends are Smart Agent addresses, so the private link survives credential rotation and name changes — the same facet doctrine the rest of the substrate runs on.
43
+
44
+ ## Boundaries
45
+
46
+ - **Storage is not here.** The vault (broker-home KV) and the query endpoints are app/broker-level; this package is shape + builder only.
47
+ - **The VC envelope and signing** belong to `verifiable-credentials`; **delegation minting** belongs to `delegation`. This package composes both, owns neither.
48
+ - **Wire shapes** — `RelatedAgentLink`, `ListRelatedAgentsResponse`, `DelegatedAgentLink`, `ListDelegatedAgentsResponse` — carry no person id.
49
+
50
+ Canonical spec: [`specs/246-related-agents-vault.md`](../../specs/246-related-agents-vault.md).
51
+
52
+ ## Validation
53
+
54
+ ```bash
55
+ pnpm --filter @agenticprimitives/related-agents typecheck
56
+ pnpm --filter @agenticprimitives/related-agents test
57
+ ```
58
+
59
+ ## Status
60
+
61
+ **w1-foundational** — the credential builder, caveat set, and wire shapes above are what ships today; storage and serving land at the app/broker layer. Testnet/pilot-ready; production launch is gated on the public checklist in the root [`README.md`](../../README.md#status--honest-version) — including third-party contract audit and governance key rotation. Track every security finding live in [`docs/audits/findings.yaml`](../../docs/audits/findings.yaml).
62
+
63
+ ## License
64
+
65
+ UNLICENSED (internal monorepo, not published).
@@ -0,0 +1,132 @@
1
+ /**
2
+ * @agenticprimitives/related-agents — private, holder-resident credentials that
3
+ * link a person to a RELATED agent (e.g. an org they created via a relying app),
4
+ * plus the scoped-delegation caveats a grantee gets to read related-agent
5
+ * metadata.
6
+ *
7
+ * person↔org is PRIVATE vault state, NEVER an on-chain edge (ADR-0025). This
8
+ * package owns the credential SHAPE + the scoped-delegation caveat set + the
9
+ * list-query types — not the storage (Connect-home vault) nor the vocabulary
10
+ * (`purpose` is a free string; no vertical terms — ADR-0021).
11
+ *
12
+ * Composes `verifiable-credentials` (DOLCE+DnS Situation + EIP-712 proof) +
13
+ * `delegation` (caveats). Sibling of `agent-relationships`, which owns ON-CHAIN
14
+ * edges only — this is the off-chain, holder-resident, private counterpart.
15
+ *
16
+ * Authoritative spec: specs/246-related-agents-vault.md
17
+ */
18
+ import { type Situation, type UnsignedCredential, type Hex32, type VisibilityTier } from '@agenticprimitives/verifiable-credentials';
19
+ import type { Address, Hex, Caveat, Delegation } from '@agenticprimitives/delegation';
20
+ export declare const PACKAGE_NAME = "@agenticprimitives/related-agents";
21
+ export declare const PACKAGE_STATUS: "w1-foundational";
22
+ export declare const SPEC_REF = "specs/246-related-agents-vault.md";
23
+ /** DOLCE Description for the related-agent situation credential. */
24
+ export declare const RELATED_AGENT_DESCRIPTION = "apra:RelatedAgentCredential";
25
+ /** The freeform body of a related-agent credential (NOT the roles/participants). */
26
+ export interface RelatedAgentBody extends Record<string, unknown> {
27
+ /** Human-readable name of the related agent (e.g. the org's `.impact` name). */
28
+ agentName: string;
29
+ /** Optional app-level kind tag (opaque to this package). */
30
+ agentKind?: string;
31
+ /** spec 271 (W0) — the recoverable custody descriptor for this related agent SA. Private (the credential
32
+ * is `visibility: private`); lets an authenticated owner reconstruct the SA's custodian (ADR-0035). */
33
+ custody?: CustodyDescriptor;
34
+ }
35
+ /** How an SA's custodian is reconstructed. For `kms-subject` the owner's `(iss,sub)` is DELIBERATELY
36
+ * absent — it is supplied by the live owner session at recovery time, so the descriptor alone never
37
+ * identifies the owner (RC-INV-3 / ADR-0025 privacy). */
38
+ export type CustodyKind = {
39
+ kind: 'kms-subject';
40
+ rotation: number;
41
+ } | {
42
+ kind: 'passkey';
43
+ credentialId: string;
44
+ } | {
45
+ kind: 'eoa';
46
+ address: Address;
47
+ };
48
+ /** The recoverable record of how an SA is custodied. Persisted (by the app/Connect, never this package)
49
+ * in the owner's PRIVATE related vault. The `salt` is the otherwise-discarded deployment salt
50
+ * (random per ADR-0010); reconstruction also needs the KMS master + an authenticated owner session, so
51
+ * the descriptor alone grants nothing (RC-INV-1). */
52
+ export interface CustodyDescriptor {
53
+ /** The SA this descriptor reconstructs the custodian for (== the credential's `relatedAgent` role). */
54
+ targetSA: Address;
55
+ /** The deployment salt (bytes32). The piece lost today when an org SA deploys with a random salt. */
56
+ salt: Hex;
57
+ /** The custodian reconstruction method. */
58
+ custody: CustodyKind;
59
+ }
60
+ /** Validate + canonicalize a custody descriptor. Rebuilds `custody` field-by-field so no extra field
61
+ * (e.g. a smuggled `iss`/`sub`) can survive into the stored record (RC-INV-3). Fail-closed on bad input. */
62
+ export declare function buildCustodyDescriptor(d: CustodyDescriptor): CustodyDescriptor;
63
+ export type RelatedAgentCredential = UnsignedCredential<Situation<{
64
+ payload: RelatedAgentBody;
65
+ }>>;
66
+ export interface BuildRelatedAgentCredentialArgs {
67
+ /** The person SA — holder AND (self-issued) issuer of the credential. */
68
+ holder: Address;
69
+ /** The related agent SA (e.g. the org). */
70
+ relatedAgent: Address;
71
+ /** App-level purpose tag, e.g. `jp-adopter-org` (free string — no vocabulary here). */
72
+ purpose: string;
73
+ /** The relying app that requested the link (its OIDC `client_id`). */
74
+ requestedBy: string;
75
+ /** CAIP-10 issuer id (the person home); `eip155:<chainId>:<holder>`. */
76
+ issuerCaip10: string;
77
+ body: RelatedAgentBody;
78
+ validFrom: string;
79
+ validUntil?: string;
80
+ /** Defaults to 'private' — person↔org links are private by default (ADR-0025). */
81
+ visibility?: VisibilityTier;
82
+ }
83
+ /** Build the unsigned, self-issued related-agent situation credential. The caller
84
+ * signs it with the holder's ROOT credential (issuer = holder = personSA). */
85
+ export declare function buildRelatedAgentCredential(args: BuildRelatedAgentCredentialArgs): RelatedAgentCredential;
86
+ /** The credential hash a relying app holds as `proofHash` (RFC-8785 JCS keccak). */
87
+ export declare function relatedAgentProofHash(credential: RelatedAgentCredential): Hex32;
88
+ export interface RelatedAgentReadCaveatArgs {
89
+ /** Deployment enforcer addresses (supplied by the app — NOT hardcoded here). */
90
+ enforcers: {
91
+ timestamp: Address;
92
+ value: Address;
93
+ allowedTargets: Address;
94
+ };
95
+ /** Unix seconds the grant is valid until. */
96
+ validUntil: number;
97
+ /** The read targets the grantee may call (e.g. naming + relationship contracts). */
98
+ allowedTargets: Address[];
99
+ /** Optional valid-after (defaults 0). */
100
+ validAfter?: number;
101
+ }
102
+ /** Build the standard scoped-read caveat set for a related-agent delegation
103
+ * (org→relying-site OR org→broker-org): time-bounded, zero-value, target-scoped.
104
+ * Reuses the `delegation` caveat primitives — no new enforcer. */
105
+ export declare function relatedAgentReadCaveats(args: RelatedAgentReadCaveatArgs): Caveat[];
106
+ /** A related-agent link a relying app receives or lists — carries NO person id. */
107
+ export interface RelatedAgentLink {
108
+ orgAgent: Address;
109
+ orgName: string;
110
+ purpose: string;
111
+ requestedBy: string;
112
+ /** The scoped org→grantee delegation. */
113
+ delegation: Delegation;
114
+ /** Hash of the private vault credential backing this link. */
115
+ proofHash: Hex32;
116
+ }
117
+ /** Response of `GET /connect/related-orgs?client_id=` (person-session-authorized). */
118
+ export interface ListRelatedAgentsResponse {
119
+ orgs: RelatedAgentLink[];
120
+ }
121
+ /** A single org that delegated to a grantee agent (e.g. the broker org). */
122
+ export interface DelegatedAgentLink {
123
+ orgAgent: Address;
124
+ orgName: string;
125
+ delegation: Delegation;
126
+ }
127
+ /** Response of `GET /connect/delegated-orgs?delegate=` (delegate-control-authorized). */
128
+ export interface ListDelegatedAgentsResponse {
129
+ orgs: DelegatedAgentLink[];
130
+ }
131
+ export type { Address, Hex };
132
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,KAAK,EACV,KAAK,cAAc,EACpB,MAAM,2CAA2C,CAAC;AAOnD,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE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C;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,yFAAyF;AACzF,MAAM,WAAW,2BAA2B;IAC1C,IAAI,EAAE,kBAAkB,EAAE,CAAC;CAC5B;AAED,YAAY,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @agenticprimitives/related-agents — private, holder-resident credentials that
3
+ * link a person to a RELATED agent (e.g. an org they created via a relying app),
4
+ * plus the scoped-delegation caveats a grantee gets to read related-agent
5
+ * metadata.
6
+ *
7
+ * person↔org is PRIVATE vault state, NEVER an on-chain edge (ADR-0025). This
8
+ * package owns the credential SHAPE + the scoped-delegation caveat set + the
9
+ * list-query types — not the storage (Connect-home vault) nor the vocabulary
10
+ * (`purpose` is a free string; no vertical terms — ADR-0021).
11
+ *
12
+ * Composes `verifiable-credentials` (DOLCE+DnS Situation + EIP-712 proof) +
13
+ * `delegation` (caveats). Sibling of `agent-relationships`, which owns ON-CHAIN
14
+ * edges only — this is the off-chain, holder-resident, private counterpart.
15
+ *
16
+ * Authoritative spec: specs/246-related-agents-vault.md
17
+ */
18
+ import { buildSituation, credentialHash, VC_CONTEXT_V2, } from '@agenticprimitives/verifiable-credentials';
19
+ import { buildCaveat, encodeTimestampTerms, encodeValueTerms, encodeAllowedTargetsTerms, } from '@agenticprimitives/delegation';
20
+ export const PACKAGE_NAME = '@agenticprimitives/related-agents';
21
+ export const PACKAGE_STATUS = 'w1-foundational';
22
+ export const SPEC_REF = 'specs/246-related-agents-vault.md';
23
+ /** DOLCE Description for the related-agent situation credential. */
24
+ export const RELATED_AGENT_DESCRIPTION = 'apra:RelatedAgentCredential';
25
+ const CD_ADDRESS = /^0x[0-9a-fA-F]{40}$/;
26
+ const CD_BYTES32 = /^0x[0-9a-fA-F]{64}$/;
27
+ /** Validate + canonicalize a custody descriptor. Rebuilds `custody` field-by-field so no extra field
28
+ * (e.g. a smuggled `iss`/`sub`) can survive into the stored record (RC-INV-3). Fail-closed on bad input. */
29
+ export function buildCustodyDescriptor(d) {
30
+ if (!CD_ADDRESS.test(d.targetSA))
31
+ throw new Error('custody descriptor: targetSA must be a 20-byte address');
32
+ if (!CD_BYTES32.test(d.salt))
33
+ throw new Error('custody descriptor: salt must be bytes32 (0x + 64 hex)');
34
+ let custody;
35
+ switch (d.custody.kind) {
36
+ case 'kms-subject': {
37
+ const { rotation } = d.custody;
38
+ if (!Number.isInteger(rotation) || rotation < 0) {
39
+ throw new Error('custody descriptor: kms-subject rotation must be a non-negative integer');
40
+ }
41
+ custody = { kind: 'kms-subject', rotation }; // explicit — drops any smuggled owner identifier
42
+ break;
43
+ }
44
+ case 'passkey': {
45
+ if (!d.custody.credentialId)
46
+ throw new Error('custody descriptor: passkey requires credentialId');
47
+ custody = { kind: 'passkey', credentialId: d.custody.credentialId };
48
+ break;
49
+ }
50
+ case 'eoa': {
51
+ if (!CD_ADDRESS.test(d.custody.address))
52
+ throw new Error('custody descriptor: eoa address invalid');
53
+ custody = { kind: 'eoa', address: d.custody.address };
54
+ break;
55
+ }
56
+ default:
57
+ throw new Error(`custody descriptor: unknown custody kind ${d.custody.kind}`);
58
+ }
59
+ return { targetSA: d.targetSA, salt: d.salt, custody };
60
+ }
61
+ /** Build the unsigned, self-issued related-agent situation credential. The caller
62
+ * signs it with the holder's ROOT credential (issuer = holder = personSA). */
63
+ export function buildRelatedAgentCredential(args) {
64
+ const situation = buildSituation({
65
+ description: RELATED_AGENT_DESCRIPTION,
66
+ roles: {
67
+ holder: args.holder,
68
+ relatedAgent: args.relatedAgent,
69
+ issuer: args.holder, // self-issued
70
+ },
71
+ body: { payload: args.body },
72
+ participants: {
73
+ purpose: args.purpose,
74
+ requestedBy: args.requestedBy,
75
+ visibility: args.visibility ?? 'private',
76
+ },
77
+ });
78
+ return {
79
+ '@context': [VC_CONTEXT_V2],
80
+ type: ['VerifiableCredential', 'RelatedAgentCredential'],
81
+ issuer: args.issuerCaip10,
82
+ validFrom: args.validFrom,
83
+ validUntil: args.validUntil,
84
+ credentialSubject: situation,
85
+ };
86
+ }
87
+ /** The credential hash a relying app holds as `proofHash` (RFC-8785 JCS keccak). */
88
+ export function relatedAgentProofHash(credential) {
89
+ return credentialHash(credential);
90
+ }
91
+ /** Build the standard scoped-read caveat set for a related-agent delegation
92
+ * (org→relying-site OR org→broker-org): time-bounded, zero-value, target-scoped.
93
+ * Reuses the `delegation` caveat primitives — no new enforcer. */
94
+ export function relatedAgentReadCaveats(args) {
95
+ return [
96
+ buildCaveat(args.enforcers.timestamp, encodeTimestampTerms(args.validAfter ?? 0, args.validUntil)),
97
+ buildCaveat(args.enforcers.value, encodeValueTerms(0n)),
98
+ buildCaveat(args.enforcers.allowedTargets, encodeAllowedTargetsTerms(args.allowedTargets)),
99
+ ];
100
+ }
101
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EACL,cAAc,EACd,cAAc,EACd,aAAa,GAKd,MAAM,2CAA2C,CAAC;AACnD,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,gBAAgB,EAChB,yBAAyB,GAC1B,MAAM,+BAA+B,CAAC;AAGvC,MAAM,CAAC,MAAM,YAAY,GAAG,mCAAmC,CAAC;AAChE,MAAM,CAAC,MAAM,cAAc,GAAG,iBAA0B,CAAC;AACzD,MAAM,CAAC,MAAM,QAAQ,GAAG,mCAAmC,CAAC;AAE5D,oEAAoE;AACpE,MAAM,CAAC,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AAoCvE,MAAM,UAAU,GAAG,qBAAqB,CAAC;AACzC,MAAM,UAAU,GAAG,qBAAqB,CAAC;AAEzC;6GAC6G;AAC7G,MAAM,UAAU,sBAAsB,CAAC,CAAoB;IACzD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,C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,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC;QACvD,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,yBAAyB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;KAC3F,CAAC;AACJ,CAAC"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@agenticprimitives/related-agents",
3
+ "version": "0.0.0-alpha.3",
4
+ "description": "Private, holder-resident related-agent credentials (person↔org links as vault situation credentials, never on-chain edges — ADR-0025) + scoped-delegation read caveats + list-query shapes. Composes verifiable-credentials + delegation.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/agentictrustlabs/agenticprimitives.git",
9
+ "directory": "packages/related-agents"
10
+ },
11
+ "homepage": "https://github.com/agentictrustlabs/agenticprimitives/tree/master/packages/related-agents",
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
+ },
24
+ "files": [
25
+ "LICENSE",
26
+ "dist",
27
+ "spec.md",
28
+ "README.md"
29
+ ],
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "peerDependencies": {
34
+ "viem": "^2.52.2"
35
+ },
36
+ "devDependencies": {
37
+ "vitest": "^4.1.8",
38
+ "viem": "^2.52.2"
39
+ },
40
+ "keywords": [
41
+ "agentic",
42
+ "primitives",
43
+ "related-agents",
44
+ "vault"
45
+ ],
46
+ "dependencies": {
47
+ "@agenticprimitives/delegation": "1.0.0-alpha.7",
48
+ "@agenticprimitives/verifiable-credentials": "0.0.0-alpha.3",
49
+ "@agenticprimitives/types": "1.0.0-alpha.7"
50
+ },
51
+ "scripts": {
52
+ "build": "tsc -p tsconfig.build.json",
53
+ "typecheck": "tsc -p tsconfig.json --noEmit",
54
+ "test": "vitest run",
55
+ "test:unit": "vitest run test/unit --passWithNoTests",
56
+ "test:watch": "vitest",
57
+ "clean": "rm -rf dist"
58
+ }
59
+ }
package/spec.md ADDED
@@ -0,0 +1,6 @@
1
+ # Spec pointer
2
+
3
+ Canonical spec: [`../../specs/246-related-agents-vault.md`](../../specs/246-related-agents-vault.md)
4
+
5
+ Architecture-of-record: [ADR-0025](../../docs/architecture/decisions/0025-related-agent-links-are-private.md)
6
+ (person↔org links are private vault credentials, not on-chain edges).