@redditech/agent-protocol 0.0.0-stage → 0.2.0
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/CHANGELOG.md +89 -0
- package/LICENSE +21 -0
- package/README.md +394 -2
- package/dist/adl.d.ts +141 -0
- package/dist/adl.js +3601 -0
- package/dist/agent-stack-fixtures.d.ts +743 -0
- package/dist/agent-stack-fixtures.js +1554 -0
- package/dist/ai-catalog.d.ts +128 -0
- package/dist/ai-catalog.js +373 -0
- package/dist/attestation-reputation.d.ts +102 -0
- package/dist/attestation-reputation.js +279 -0
- package/dist/audd-rail-config.d.ts +102 -0
- package/dist/audd-rail-config.js +294 -0
- package/dist/browser-wallet-approval.d.ts +293 -0
- package/dist/browser-wallet-approval.js +1201 -0
- package/dist/discovery-source.d.ts +115 -0
- package/dist/discovery-source.js +251 -0
- package/dist/evidence-archive.d.ts +73 -0
- package/dist/evidence-archive.js +238 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +23 -0
- package/dist/mpp-tempo-receipt-shapes.d.ts +201 -0
- package/dist/mpp-tempo-receipt-shapes.js +330 -0
- package/dist/okf-adapter.d.ts +229 -0
- package/dist/okf-adapter.js +556 -0
- package/dist/okf-conformance.d.ts +208 -0
- package/dist/okf-conformance.js +651 -0
- package/dist/okf-instruction-safety.d.ts +192 -0
- package/dist/okf-instruction-safety.js +509 -0
- package/dist/onboarding-analyser-handoff.d.ts +391 -0
- package/dist/onboarding-analyser-handoff.js +959 -0
- package/dist/onboarding-state-machine.d.ts +228 -0
- package/dist/onboarding-state-machine.js +432 -0
- package/dist/payment-records.d.ts +181 -0
- package/dist/payment-records.js +599 -0
- package/dist/policy.d.ts +33 -0
- package/dist/policy.js +45 -0
- package/dist/provider-trust.d.ts +113 -0
- package/dist/provider-trust.js +346 -0
- package/dist/quasar-registry-compatibility.d.ts +113 -0
- package/dist/quasar-registry-compatibility.js +214 -0
- package/dist/ranking-explainability.d.ts +202 -0
- package/dist/ranking-explainability.js +302 -0
- package/dist/receipt-v2.d.ts +202 -0
- package/dist/receipt-v2.js +418 -0
- package/dist/repo-explorer-evidence-manifest.d.ts +387 -0
- package/dist/repo-explorer-evidence-manifest.js +1187 -0
- package/dist/source-diagnostics.d.ts +84 -0
- package/dist/source-diagnostics.js +193 -0
- package/dist/source-trust-conformance-matrix.d.ts +207 -0
- package/dist/source-trust-conformance-matrix.js +672 -0
- package/examples/ard-no-spend-ai-catalog.json +51 -0
- package/examples/ard-no-spend-demo.mjs +355 -0
- package/examples/interpretation-guide-scenarios.mjs +302 -0
- package/package.json +144 -4
package/dist/policy.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export const REDDI_POLICY_REASON_CODES = [
|
|
2
|
+
'allowed',
|
|
3
|
+
'budget_policy_missing',
|
|
4
|
+
'invalid_quote',
|
|
5
|
+
'malformed_limit',
|
|
6
|
+
'request_amount_exceeds_limit',
|
|
7
|
+
'session_budget_exceeded',
|
|
8
|
+
'source_budget_exceeded',
|
|
9
|
+
'specialist_budget_exceeded',
|
|
10
|
+
'asset_network_budget_exceeded',
|
|
11
|
+
'call_count_exceeded',
|
|
12
|
+
'unsupported_asset_network',
|
|
13
|
+
'operator_denied',
|
|
14
|
+
'operator_approval_required',
|
|
15
|
+
'payment_proof_missing',
|
|
16
|
+
'unsupported_network_asset',
|
|
17
|
+
'malformed_receipt',
|
|
18
|
+
'credential_leakage_rejected',
|
|
19
|
+
];
|
|
20
|
+
export function policyDecisionFromBudgetPolicyDecision(decision, options = {}) {
|
|
21
|
+
const asset = decision.quotedAmount?.asset ?? 'unknown';
|
|
22
|
+
const network = decision.quotedAmount?.network ?? 'unknown';
|
|
23
|
+
return {
|
|
24
|
+
schemaVersion: 'reddi.policy-decision.v1',
|
|
25
|
+
allowed: decision.allowed,
|
|
26
|
+
reasonCodes: normalizeReasonCodes(decision.reasonCodes),
|
|
27
|
+
quotedAmount: decision.quotedAmount,
|
|
28
|
+
limits: decision.remainingBudget,
|
|
29
|
+
asset,
|
|
30
|
+
network,
|
|
31
|
+
approvalState: options.approvalState ?? (decision.allowed ? 'approved' : 'denied'),
|
|
32
|
+
auditNotes: decision.auditNotes,
|
|
33
|
+
operatorNote: options.operatorNote,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function normalizeReasonCodes(codes) {
|
|
37
|
+
return codes.map((code) => {
|
|
38
|
+
if (isReddiPolicyReasonCode(code))
|
|
39
|
+
return code;
|
|
40
|
+
throw new Error(`unsupported_policy_reason_code:${code}`);
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export function isReddiPolicyReasonCode(code) {
|
|
44
|
+
return typeof code === 'string' && REDDI_POLICY_REASON_CODES.includes(code);
|
|
45
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { type AiCatalogSnapshot } from './ai-catalog.js';
|
|
2
|
+
export declare const PROVIDER_TRUST_RECORD_SCHEMA_VERSION: "reddi.provider-trust.v1";
|
|
3
|
+
export type ProviderTrustVerificationStatus = 'claimed' | 'verified' | 'unverified' | 'failed_verification';
|
|
4
|
+
export type ProviderTrustReasonCode = 'rap_verified' | 'rap_verification_failed' | 'external_claim_not_verified_by_rap' | 'no_trust_metadata' | 'provider_not_found' | 'malformed_trust_metadata' | 'credential_leakage_rejected';
|
|
5
|
+
export type ProviderTrustValidationError = {
|
|
6
|
+
code: ProviderTrustReasonCode;
|
|
7
|
+
path: string;
|
|
8
|
+
message: string;
|
|
9
|
+
};
|
|
10
|
+
export type ProviderTrustRecord = {
|
|
11
|
+
schemaVersion: typeof PROVIDER_TRUST_RECORD_SCHEMA_VERSION;
|
|
12
|
+
provider: {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
mediaType: string;
|
|
16
|
+
url?: string;
|
|
17
|
+
};
|
|
18
|
+
publisher: {
|
|
19
|
+
id: string;
|
|
20
|
+
name?: string;
|
|
21
|
+
domain?: string;
|
|
22
|
+
};
|
|
23
|
+
source: {
|
|
24
|
+
kind: 'ai-catalog';
|
|
25
|
+
rawSnapshotRef?: string;
|
|
26
|
+
catalogPublisherId: string;
|
|
27
|
+
};
|
|
28
|
+
verification: {
|
|
29
|
+
status: ProviderTrustVerificationStatus;
|
|
30
|
+
reasonCodes: ProviderTrustReasonCode[];
|
|
31
|
+
verifier?: string;
|
|
32
|
+
checkedAt?: string;
|
|
33
|
+
failureReasons: string[];
|
|
34
|
+
};
|
|
35
|
+
trustMetadata: {
|
|
36
|
+
trustManifest?: unknown;
|
|
37
|
+
provenanceLinks: unknown[];
|
|
38
|
+
attestations: unknown[];
|
|
39
|
+
detachedSignature?: unknown;
|
|
40
|
+
verificationReferences: unknown[];
|
|
41
|
+
publisherIdentity?: unknown;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export type ProviderTrustVerificationInput = {
|
|
45
|
+
status?: Extract<ProviderTrustVerificationStatus, 'verified' | 'failed_verification'>;
|
|
46
|
+
verifier?: string;
|
|
47
|
+
checkedAt?: string;
|
|
48
|
+
failureReasons?: string[];
|
|
49
|
+
};
|
|
50
|
+
export type NormalizeAiCatalogTrustOptions = {
|
|
51
|
+
verification?: ProviderTrustVerificationInput;
|
|
52
|
+
};
|
|
53
|
+
export type ProviderTrustNormalizationResult = {
|
|
54
|
+
ok: true;
|
|
55
|
+
record: ProviderTrustRecord;
|
|
56
|
+
} | {
|
|
57
|
+
ok: false;
|
|
58
|
+
errors: ProviderTrustValidationError[];
|
|
59
|
+
};
|
|
60
|
+
export type ProviderTrustFixtureCase = {
|
|
61
|
+
description: string;
|
|
62
|
+
catalog: AiCatalogSnapshot;
|
|
63
|
+
resourceId: string;
|
|
64
|
+
options?: NormalizeAiCatalogTrustOptions;
|
|
65
|
+
expectedValid: boolean;
|
|
66
|
+
expectedStatus?: ProviderTrustVerificationStatus;
|
|
67
|
+
expectedReasonCodes: ProviderTrustReasonCode[];
|
|
68
|
+
};
|
|
69
|
+
export declare function normalizeAiCatalogProviderTrustRecord(catalog: AiCatalogSnapshot, resourceId: string, options?: NormalizeAiCatalogTrustOptions): ProviderTrustNormalizationResult;
|
|
70
|
+
export declare function createAiCatalogProviderTrustRecord(catalog: AiCatalogSnapshot, resourceId: string, options?: NormalizeAiCatalogTrustOptions): ProviderTrustRecord;
|
|
71
|
+
export declare const providerTrustFixtures: {
|
|
72
|
+
readonly verifiedCatalog: AiCatalogSnapshot;
|
|
73
|
+
readonly unverifiedCatalog: AiCatalogSnapshot;
|
|
74
|
+
readonly malformedTrustCatalog: AiCatalogSnapshot;
|
|
75
|
+
readonly credentialBearingCatalog: {
|
|
76
|
+
schemaVersion: "ai-catalog.v1";
|
|
77
|
+
publisher: {
|
|
78
|
+
id: string;
|
|
79
|
+
};
|
|
80
|
+
rawSnapshotRef: string;
|
|
81
|
+
resources: {
|
|
82
|
+
id: string;
|
|
83
|
+
type: string;
|
|
84
|
+
mediaType: string;
|
|
85
|
+
name: string;
|
|
86
|
+
url: string;
|
|
87
|
+
trustManifest: {
|
|
88
|
+
identity: string;
|
|
89
|
+
};
|
|
90
|
+
auth: {
|
|
91
|
+
token: string;
|
|
92
|
+
};
|
|
93
|
+
raw: {
|
|
94
|
+
identifier: string;
|
|
95
|
+
displayName: string;
|
|
96
|
+
mediaType: string;
|
|
97
|
+
url: string;
|
|
98
|
+
trustManifest: {
|
|
99
|
+
identity: string;
|
|
100
|
+
};
|
|
101
|
+
metadata: {
|
|
102
|
+
trust: {
|
|
103
|
+
provenance: string[];
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
auth: {
|
|
107
|
+
token: string;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
}[];
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export declare const providerTrustFixtureCases: Record<string, ProviderTrustFixtureCase>;
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
import { aiCatalogFixtures, createAiCatalogSnapshot } from './ai-catalog.js';
|
|
2
|
+
export const PROVIDER_TRUST_RECORD_SCHEMA_VERSION = 'reddi.provider-trust.v1';
|
|
3
|
+
const SENSITIVE_KEY_PATTERN = /(^|[_-])(api[_-]?key|authorization|bearer|cookie|credential|mnemonic|password|private[_-]?key|refresh[_-]?token|secret|seed|session[_-]?token|token)($|[_-])|apiKey|accessToken|refreshToken|sessionToken|privateKey/i;
|
|
4
|
+
const SENSITIVE_VALUE_PATTERN = /(-----BEGIN [A-Z ]*PRIVATE KEY-----|authorization:\s*bearer\s+|bearer\s+[a-z0-9._-]{8,}|sk-[a-z0-9_-]{8,})/i;
|
|
5
|
+
function isPlainObject(value) {
|
|
6
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
7
|
+
return false;
|
|
8
|
+
const prototype = Object.getPrototypeOf(value);
|
|
9
|
+
return prototype === Object.prototype || prototype === null;
|
|
10
|
+
}
|
|
11
|
+
function asString(value) {
|
|
12
|
+
return typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
13
|
+
}
|
|
14
|
+
function collectTrustList(value, path, errors) {
|
|
15
|
+
if (value === undefined)
|
|
16
|
+
return [];
|
|
17
|
+
const values = Array.isArray(value) ? value : [value];
|
|
18
|
+
for (let index = 0; index < values.length; index += 1) {
|
|
19
|
+
const item = values[index];
|
|
20
|
+
if (typeof item !== 'string' && !isPlainObject(item)) {
|
|
21
|
+
errors.push(error('malformed_trust_metadata', `${path}${Array.isArray(value) ? `[${index}]` : ''}`, 'trust metadata references must be strings or objects.'));
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return values;
|
|
25
|
+
}
|
|
26
|
+
function validateOptionalStringOrObject(value, path, errors) {
|
|
27
|
+
if (value === undefined)
|
|
28
|
+
return undefined;
|
|
29
|
+
if (typeof value === 'string' || isPlainObject(value))
|
|
30
|
+
return value;
|
|
31
|
+
errors.push(error('malformed_trust_metadata', path, 'trust metadata field must be a string or object.'));
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
function error(code, path, message) {
|
|
35
|
+
return { code, path, message };
|
|
36
|
+
}
|
|
37
|
+
function findCredentialMaterial(value, path = '$') {
|
|
38
|
+
if (typeof value === 'string')
|
|
39
|
+
return SENSITIVE_VALUE_PATTERN.test(value) ? path : undefined;
|
|
40
|
+
if (!value || typeof value !== 'object')
|
|
41
|
+
return undefined;
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
44
|
+
const found = findCredentialMaterial(value[index], `${path}[${index}]`);
|
|
45
|
+
if (found)
|
|
46
|
+
return found;
|
|
47
|
+
}
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
for (const [key, child] of Object.entries(value)) {
|
|
51
|
+
const childPath = `${path}.${key}`;
|
|
52
|
+
if (SENSITIVE_KEY_PATTERN.test(key))
|
|
53
|
+
return childPath;
|
|
54
|
+
const found = findCredentialMaterial(child, childPath);
|
|
55
|
+
if (found)
|
|
56
|
+
return found;
|
|
57
|
+
}
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
function metadataObject(resource) {
|
|
61
|
+
return isPlainObject(resource.raw) && isPlainObject(resource.raw.metadata) ? resource.raw.metadata : undefined;
|
|
62
|
+
}
|
|
63
|
+
function trustObject(resource) {
|
|
64
|
+
const metadata = metadataObject(resource);
|
|
65
|
+
if (metadata && isPlainObject(metadata.trust))
|
|
66
|
+
return metadata.trust;
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
function hasTrustMetadata(record) {
|
|
70
|
+
return Boolean(record.trustManifest
|
|
71
|
+
|| record.detachedSignature
|
|
72
|
+
|| record.publisherIdentity
|
|
73
|
+
|| record.provenanceLinks.length > 0
|
|
74
|
+
|| record.attestations.length > 0
|
|
75
|
+
|| record.verificationReferences.length > 0);
|
|
76
|
+
}
|
|
77
|
+
function collectTrustMetadata(resource, errors) {
|
|
78
|
+
const raw = isPlainObject(resource.raw) ? resource.raw : {};
|
|
79
|
+
const metadata = metadataObject(resource);
|
|
80
|
+
const trust = trustObject(resource);
|
|
81
|
+
const trustManifest = resource.trustManifest ?? trust?.trustManifest ?? metadata?.trustManifest;
|
|
82
|
+
if (trustManifest !== undefined && typeof trustManifest !== 'string' && !isPlainObject(trustManifest)) {
|
|
83
|
+
errors.push(error('malformed_trust_metadata', '$.trustManifest', 'trustManifest must be a URL string or object.'));
|
|
84
|
+
}
|
|
85
|
+
const manifestObject = isPlainObject(trustManifest) ? trustManifest : undefined;
|
|
86
|
+
const detachedSignature = raw.detachedSignature ?? raw.signature ?? trust?.detachedSignature ?? trust?.signature ?? manifestObject?.signature;
|
|
87
|
+
if (detachedSignature !== undefined && typeof detachedSignature !== 'string' && !isPlainObject(detachedSignature)) {
|
|
88
|
+
errors.push(error('malformed_trust_metadata', '$.detachedSignature', 'detached-signature metadata must be a string or object.'));
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
trustManifest,
|
|
92
|
+
provenanceLinks: [
|
|
93
|
+
...collectTrustList(manifestObject?.provenance, '$.trustManifest.provenance', errors),
|
|
94
|
+
...collectTrustList(manifestObject?.provenanceLinks, '$.trustManifest.provenanceLinks', errors),
|
|
95
|
+
...collectTrustList(raw.provenance, '$.provenance', errors),
|
|
96
|
+
...collectTrustList(raw.provenanceLinks, '$.provenanceLinks', errors),
|
|
97
|
+
...collectTrustList(trust?.provenance, '$.metadata.trust.provenance', errors),
|
|
98
|
+
...collectTrustList(trust?.provenanceLinks, '$.metadata.trust.provenanceLinks', errors),
|
|
99
|
+
],
|
|
100
|
+
attestations: [
|
|
101
|
+
...collectTrustList(manifestObject?.attestations, '$.trustManifest.attestations', errors),
|
|
102
|
+
...collectTrustList(raw.attestations, '$.attestations', errors),
|
|
103
|
+
...collectTrustList(trust?.attestations, '$.metadata.trust.attestations', errors),
|
|
104
|
+
],
|
|
105
|
+
detachedSignature,
|
|
106
|
+
verificationReferences: [
|
|
107
|
+
...collectTrustList(manifestObject?.verification, '$.trustManifest.verification', errors),
|
|
108
|
+
...collectTrustList(manifestObject?.verificationReferences, '$.trustManifest.verificationReferences', errors),
|
|
109
|
+
...collectTrustList(raw.verification, '$.verification', errors),
|
|
110
|
+
...collectTrustList(raw.verificationReferences, '$.verificationReferences', errors),
|
|
111
|
+
...collectTrustList(trust?.verification, '$.metadata.trust.verification', errors),
|
|
112
|
+
...collectTrustList(trust?.verificationReferences, '$.metadata.trust.verificationReferences', errors),
|
|
113
|
+
],
|
|
114
|
+
publisherIdentity: validateOptionalStringOrObject(raw.publisherIdentity ?? trust?.publisherIdentity ?? metadata?.publisherIdentity ?? manifestObject?.publisherIdentity, '$.publisherIdentity', errors),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
function buildVerification(metadata, verification) {
|
|
118
|
+
const failureReasons = verification?.failureReasons ?? [];
|
|
119
|
+
if (verification?.status === 'verified') {
|
|
120
|
+
return {
|
|
121
|
+
status: 'verified',
|
|
122
|
+
reasonCodes: ['rap_verified'],
|
|
123
|
+
verifier: verification.verifier,
|
|
124
|
+
checkedAt: verification.checkedAt,
|
|
125
|
+
failureReasons: [],
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
if (verification?.status === 'failed_verification') {
|
|
129
|
+
return {
|
|
130
|
+
status: 'failed_verification',
|
|
131
|
+
reasonCodes: ['rap_verification_failed'],
|
|
132
|
+
verifier: verification.verifier,
|
|
133
|
+
checkedAt: verification.checkedAt,
|
|
134
|
+
failureReasons,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
if (hasTrustMetadata(metadata)) {
|
|
138
|
+
return {
|
|
139
|
+
status: 'claimed',
|
|
140
|
+
reasonCodes: ['external_claim_not_verified_by_rap'],
|
|
141
|
+
failureReasons: [],
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
return {
|
|
145
|
+
status: 'unverified',
|
|
146
|
+
reasonCodes: ['no_trust_metadata'],
|
|
147
|
+
failureReasons: [],
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
export function normalizeAiCatalogProviderTrustRecord(catalog, resourceId, options = {}) {
|
|
151
|
+
const resource = catalog.resources.find((item) => item.id === resourceId);
|
|
152
|
+
if (!resource) {
|
|
153
|
+
return {
|
|
154
|
+
ok: false,
|
|
155
|
+
errors: [error('provider_not_found', '$.resourceId', `No AI Catalog resource found for ${resourceId}.`)],
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
const errors = [];
|
|
159
|
+
const credentialPath = findCredentialMaterial({
|
|
160
|
+
trustManifest: resource.trustManifest,
|
|
161
|
+
payment: resource.payment,
|
|
162
|
+
auth: resource.auth,
|
|
163
|
+
raw: resource.raw,
|
|
164
|
+
});
|
|
165
|
+
if (credentialPath) {
|
|
166
|
+
errors.push(error('credential_leakage_rejected', credentialPath, 'provider trust metadata contains credential-shaped material.'));
|
|
167
|
+
}
|
|
168
|
+
const trustMetadata = collectTrustMetadata(resource, errors);
|
|
169
|
+
if (errors.length > 0)
|
|
170
|
+
return { ok: false, errors };
|
|
171
|
+
const record = {
|
|
172
|
+
schemaVersion: PROVIDER_TRUST_RECORD_SCHEMA_VERSION,
|
|
173
|
+
provider: {
|
|
174
|
+
id: resource.id,
|
|
175
|
+
name: resource.name,
|
|
176
|
+
mediaType: resource.mediaType,
|
|
177
|
+
url: resource.url ?? resource.endpoint ?? resource.catalogUrl,
|
|
178
|
+
},
|
|
179
|
+
publisher: {
|
|
180
|
+
id: catalog.publisher.id,
|
|
181
|
+
name: catalog.publisher.name,
|
|
182
|
+
domain: catalog.publisher.domain,
|
|
183
|
+
},
|
|
184
|
+
source: {
|
|
185
|
+
kind: 'ai-catalog',
|
|
186
|
+
rawSnapshotRef: catalog.rawSnapshotRef,
|
|
187
|
+
catalogPublisherId: catalog.publisher.id,
|
|
188
|
+
},
|
|
189
|
+
verification: buildVerification(trustMetadata, options.verification),
|
|
190
|
+
trustMetadata,
|
|
191
|
+
};
|
|
192
|
+
return { ok: true, record };
|
|
193
|
+
}
|
|
194
|
+
export function createAiCatalogProviderTrustRecord(catalog, resourceId, options = {}) {
|
|
195
|
+
const result = normalizeAiCatalogProviderTrustRecord(catalog, resourceId, options);
|
|
196
|
+
if (!result.ok) {
|
|
197
|
+
throw new Error(`invalid_provider_trust_record:${result.errors.map((item) => item.code).join(',')}`);
|
|
198
|
+
}
|
|
199
|
+
return result.record;
|
|
200
|
+
}
|
|
201
|
+
export const providerTrustFixtures = {
|
|
202
|
+
verifiedCatalog: createAiCatalogSnapshot({
|
|
203
|
+
...aiCatalogFixtures.happyPath,
|
|
204
|
+
entries: [
|
|
205
|
+
{
|
|
206
|
+
...aiCatalogFixtures.happyPath.entries[0],
|
|
207
|
+
trustManifest: {
|
|
208
|
+
identity: 'urn:ai:reddi.tech:specialists:code-review',
|
|
209
|
+
provenance: ['https://agents.reddi.tech/provenance/code-review.json'],
|
|
210
|
+
attestations: [{ type: 'build-provenance', ref: 'sha256:attestation-fixture' }],
|
|
211
|
+
signature: {
|
|
212
|
+
format: 'dsse',
|
|
213
|
+
ref: 'https://agents.reddi.tech/signatures/code-review.dsse',
|
|
214
|
+
status: 'claimed',
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
metadata: {
|
|
218
|
+
...aiCatalogFixtures.happyPath.entries[0].metadata,
|
|
219
|
+
trust: {
|
|
220
|
+
verificationReferences: ['https://agents.reddi.tech/verification/code-review.json'],
|
|
221
|
+
publisherIdentity: { domain: 'reddi.tech', status: 'claimed' },
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
],
|
|
226
|
+
}, { rawSnapshotRef: 'sha256:verified-catalog-fixture' }),
|
|
227
|
+
unverifiedCatalog: createAiCatalogSnapshot({
|
|
228
|
+
specVersion: '1.0',
|
|
229
|
+
host: { identifier: 'example.com', displayName: 'Example Agents' },
|
|
230
|
+
entries: [
|
|
231
|
+
{
|
|
232
|
+
identifier: 'urn:example:agents:summary',
|
|
233
|
+
displayName: 'Summary Agent',
|
|
234
|
+
mediaType: 'application/mcp-server-card+json',
|
|
235
|
+
url: 'https://agents.example.com/summary/mcp.json',
|
|
236
|
+
},
|
|
237
|
+
],
|
|
238
|
+
}, { rawSnapshotRef: 'sha256:unverified-catalog-fixture' }),
|
|
239
|
+
malformedTrustCatalog: createAiCatalogSnapshot({
|
|
240
|
+
specVersion: '1.0',
|
|
241
|
+
host: 'example.com',
|
|
242
|
+
entries: [
|
|
243
|
+
{
|
|
244
|
+
identifier: 'urn:example:agents:malformed-trust',
|
|
245
|
+
displayName: 'Malformed Trust Agent',
|
|
246
|
+
mediaType: 'application/mcp-server-card+json',
|
|
247
|
+
url: 'https://agents.example.com/malformed/mcp.json',
|
|
248
|
+
trustManifest: 42,
|
|
249
|
+
},
|
|
250
|
+
],
|
|
251
|
+
}, { rawSnapshotRef: 'sha256:malformed-trust-fixture' }),
|
|
252
|
+
credentialBearingCatalog: {
|
|
253
|
+
schemaVersion: 'ai-catalog.v1',
|
|
254
|
+
publisher: { id: 'example.com' },
|
|
255
|
+
rawSnapshotRef: 'sha256:credential-bearing-trust-fixture',
|
|
256
|
+
resources: [
|
|
257
|
+
{
|
|
258
|
+
id: 'urn:example:agents:credential-bearing',
|
|
259
|
+
type: 'application/mcp-server-card+json',
|
|
260
|
+
mediaType: 'application/mcp-server-card+json',
|
|
261
|
+
name: 'Credential Bearing Agent',
|
|
262
|
+
url: 'https://agents.example.com/credential-safe-url/mcp.json',
|
|
263
|
+
trustManifest: { identity: 'urn:example:agents:credential-bearing' },
|
|
264
|
+
auth: {
|
|
265
|
+
token: 'redacted-but-still-secret-shaped',
|
|
266
|
+
},
|
|
267
|
+
raw: {
|
|
268
|
+
identifier: 'urn:example:agents:credential-bearing',
|
|
269
|
+
displayName: 'Credential Bearing Agent',
|
|
270
|
+
mediaType: 'application/mcp-server-card+json',
|
|
271
|
+
url: 'https://agents.example.com/credential-safe-url/mcp.json',
|
|
272
|
+
trustManifest: { identity: 'urn:example:agents:credential-bearing' },
|
|
273
|
+
metadata: {
|
|
274
|
+
trust: { provenance: ['https://agents.example.com/provenance.json'] },
|
|
275
|
+
},
|
|
276
|
+
auth: {
|
|
277
|
+
token: 'redacted-but-still-secret-shaped',
|
|
278
|
+
},
|
|
279
|
+
},
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
export const providerTrustFixtureCases = {
|
|
285
|
+
verified: {
|
|
286
|
+
description: 'RAP-side verification upgrades externally claimed metadata to verified.',
|
|
287
|
+
catalog: providerTrustFixtures.verifiedCatalog,
|
|
288
|
+
resourceId: 'urn:ai:reddi.tech:specialists:code-review',
|
|
289
|
+
options: {
|
|
290
|
+
verification: {
|
|
291
|
+
status: 'verified',
|
|
292
|
+
verifier: 'rap:local-fixture',
|
|
293
|
+
checkedAt: '2026-06-18T10:55:00.000Z',
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
expectedValid: true,
|
|
297
|
+
expectedStatus: 'verified',
|
|
298
|
+
expectedReasonCodes: ['rap_verified'],
|
|
299
|
+
},
|
|
300
|
+
claimed: {
|
|
301
|
+
description: 'External trust metadata remains claimed until RAP verifies it.',
|
|
302
|
+
catalog: providerTrustFixtures.verifiedCatalog,
|
|
303
|
+
resourceId: 'urn:ai:reddi.tech:specialists:code-review',
|
|
304
|
+
expectedValid: true,
|
|
305
|
+
expectedStatus: 'claimed',
|
|
306
|
+
expectedReasonCodes: ['external_claim_not_verified_by_rap'],
|
|
307
|
+
},
|
|
308
|
+
unverified: {
|
|
309
|
+
description: 'Provider without trust metadata stays unverified.',
|
|
310
|
+
catalog: providerTrustFixtures.unverifiedCatalog,
|
|
311
|
+
resourceId: 'urn:example:agents:summary',
|
|
312
|
+
expectedValid: true,
|
|
313
|
+
expectedStatus: 'unverified',
|
|
314
|
+
expectedReasonCodes: ['no_trust_metadata'],
|
|
315
|
+
},
|
|
316
|
+
failedVerification: {
|
|
317
|
+
description: 'RAP-side verification failure is explicit and carries failure reasons.',
|
|
318
|
+
catalog: providerTrustFixtures.verifiedCatalog,
|
|
319
|
+
resourceId: 'urn:ai:reddi.tech:specialists:code-review',
|
|
320
|
+
options: {
|
|
321
|
+
verification: {
|
|
322
|
+
status: 'failed_verification',
|
|
323
|
+
verifier: 'rap:local-fixture',
|
|
324
|
+
checkedAt: '2026-06-18T10:55:00.000Z',
|
|
325
|
+
failureReasons: ['signature_ref_not_available'],
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
expectedValid: true,
|
|
329
|
+
expectedStatus: 'failed_verification',
|
|
330
|
+
expectedReasonCodes: ['rap_verification_failed'],
|
|
331
|
+
},
|
|
332
|
+
malformedTrustManifest: {
|
|
333
|
+
description: 'Malformed trust manifest fails closed.',
|
|
334
|
+
catalog: providerTrustFixtures.malformedTrustCatalog,
|
|
335
|
+
resourceId: 'urn:example:agents:malformed-trust',
|
|
336
|
+
expectedValid: false,
|
|
337
|
+
expectedReasonCodes: ['malformed_trust_metadata'],
|
|
338
|
+
},
|
|
339
|
+
credentialBearingMetadata: {
|
|
340
|
+
description: 'Credential-bearing auth/payment/trust metadata fails closed.',
|
|
341
|
+
catalog: providerTrustFixtures.credentialBearingCatalog,
|
|
342
|
+
resourceId: 'urn:example:agents:credential-bearing',
|
|
343
|
+
expectedValid: false,
|
|
344
|
+
expectedReasonCodes: ['credential_leakage_rejected'],
|
|
345
|
+
},
|
|
346
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
export declare const QUASAR_REGISTRY_COMPATIBILITY_SCHEMA_VERSION: "reddi.quasar-registry-compatibility.v1";
|
|
2
|
+
export declare const QUASAR_AGENT_ACCOUNT_COMPATIBILITY: {
|
|
3
|
+
readonly discriminator: readonly [20];
|
|
4
|
+
readonly dataSize: 153;
|
|
5
|
+
readonly pdaSeed: "agent";
|
|
6
|
+
readonly modelMaxBytes: 64;
|
|
7
|
+
readonly onchainFieldNames: readonly ["owner", "agentType", "model", "rateLamports", "minReputation", "active", "reputationScore", "jobsCompleted", "jobsFailed", "createdAt", "attestationAccuracy"];
|
|
8
|
+
readonly offchainFieldNames: readonly ["profileId", "listingId", "displayName", "summary", "description", "buyerPreview", "endpoint", "ardUrl", "catalogRefs", "sourceRefs", "authRequirements", "auddTerms", "evidenceRefs", "receiptRefs", "trustBadges", "providerTrustStatus", "capabilities", "tags", "groups", "riskDiagnostics", "reviewStates", "operatorApprovalEvidenceRef"];
|
|
9
|
+
};
|
|
10
|
+
export type QuasarRegistryAgentType = 'Primary' | 'Attestation' | 'Both';
|
|
11
|
+
export type QuasarRegistryRegistrationIntent = 'metadata_only' | 'register' | 'update';
|
|
12
|
+
export type QuasarRegistryRegistrationStatus = 'metadata_only' | 'registerable' | 'blocked';
|
|
13
|
+
export type QuasarRegistryCompatibilityInput = {
|
|
14
|
+
profileId?: string;
|
|
15
|
+
listingId: string;
|
|
16
|
+
displayName: string;
|
|
17
|
+
summary?: string;
|
|
18
|
+
description?: string;
|
|
19
|
+
owner?: string;
|
|
20
|
+
role?: {
|
|
21
|
+
callable?: boolean;
|
|
22
|
+
attestation?: boolean;
|
|
23
|
+
};
|
|
24
|
+
model?: string;
|
|
25
|
+
nativeSolRateLamports?: string | bigint | number;
|
|
26
|
+
minReputation?: number;
|
|
27
|
+
registrationIntent?: QuasarRegistryRegistrationIntent;
|
|
28
|
+
active?: boolean;
|
|
29
|
+
decodedAggregates?: {
|
|
30
|
+
reputationScore?: number;
|
|
31
|
+
jobsCompleted?: string | bigint | number;
|
|
32
|
+
jobsFailed?: string | bigint | number;
|
|
33
|
+
createdAt?: string | bigint | number;
|
|
34
|
+
attestationAccuracy?: number;
|
|
35
|
+
};
|
|
36
|
+
offchain: {
|
|
37
|
+
buyerPreview?: string;
|
|
38
|
+
endpoint?: {
|
|
39
|
+
url?: string;
|
|
40
|
+
bindingRef?: string;
|
|
41
|
+
healthStatus?: 'not_probed' | 'healthy' | 'unhealthy' | 'unknown';
|
|
42
|
+
};
|
|
43
|
+
ardUrl?: string;
|
|
44
|
+
catalogRefs?: string[];
|
|
45
|
+
sourceRefs?: string[];
|
|
46
|
+
authRequirements?: string[];
|
|
47
|
+
auddTerms?: {
|
|
48
|
+
asset: string;
|
|
49
|
+
network: string;
|
|
50
|
+
amount?: string;
|
|
51
|
+
paymentPlanRef?: string;
|
|
52
|
+
quoteRef?: string;
|
|
53
|
+
settlementAccount?: string;
|
|
54
|
+
refundPolicy?: string;
|
|
55
|
+
failurePolicy?: string;
|
|
56
|
+
};
|
|
57
|
+
evidenceRefs?: string[];
|
|
58
|
+
receiptRefs?: string[];
|
|
59
|
+
trustBadges?: string[];
|
|
60
|
+
providerTrustStatus?: 'unverified' | 'self_attested' | 'external_attested' | 'reddi_attested' | 'verified';
|
|
61
|
+
capabilities?: string[];
|
|
62
|
+
tags?: string[];
|
|
63
|
+
groups?: string[];
|
|
64
|
+
riskDiagnostics?: string[];
|
|
65
|
+
reviewStates?: string[];
|
|
66
|
+
operatorApprovalEvidenceRef?: string;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export type QuasarRegistryCompatibilityReport = {
|
|
70
|
+
schemaVersion: typeof QUASAR_REGISTRY_COMPATIBILITY_SCHEMA_VERSION;
|
|
71
|
+
profileId?: string;
|
|
72
|
+
listingId: string;
|
|
73
|
+
registrationStatus: QuasarRegistryRegistrationStatus;
|
|
74
|
+
account: typeof QUASAR_AGENT_ACCOUNT_COMPATIBILITY;
|
|
75
|
+
onchain: {
|
|
76
|
+
owner?: string;
|
|
77
|
+
agentType: QuasarRegistryAgentType;
|
|
78
|
+
model: string;
|
|
79
|
+
rateLamports?: string;
|
|
80
|
+
minReputation: number;
|
|
81
|
+
active: boolean;
|
|
82
|
+
aggregates: {
|
|
83
|
+
source: 'decoded_quasar_account' | 'not_available';
|
|
84
|
+
reputationScore?: number;
|
|
85
|
+
jobsCompleted?: string;
|
|
86
|
+
jobsFailed?: string;
|
|
87
|
+
createdAt?: string;
|
|
88
|
+
attestationAccuracy?: number;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
offchain: QuasarRegistryCompatibilityInput['offchain'] & {
|
|
92
|
+
profileId?: string;
|
|
93
|
+
listingId: string;
|
|
94
|
+
displayName: string;
|
|
95
|
+
summary?: string;
|
|
96
|
+
description?: string;
|
|
97
|
+
};
|
|
98
|
+
blockedReasons: string[];
|
|
99
|
+
reasonCodes: string[];
|
|
100
|
+
guardrails: {
|
|
101
|
+
richMetadataOnchain: false;
|
|
102
|
+
auddCustodyOnchain: false;
|
|
103
|
+
endpointOnchain: false;
|
|
104
|
+
evidencePayloadOnchain: false;
|
|
105
|
+
trustBadgeOnchain: false;
|
|
106
|
+
instructionBuilt: false;
|
|
107
|
+
walletSigning: false;
|
|
108
|
+
rpcCall: false;
|
|
109
|
+
programDeploy: false;
|
|
110
|
+
livePaymentExecuted: false;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
export declare function deriveQuasarRegistryCompatibility(input: QuasarRegistryCompatibilityInput): QuasarRegistryCompatibilityReport;
|