| 1 | import { mkdir, writeFile } from 'node:fs/promises';
|
| 2 | import { z } from 'zod';
|
| 3 | import {
|
| 4 | AgentIdentitySchema,
|
| 5 | AgentTransportSchema,
|
| 6 | DelegationCredentialSchema,
|
| 7 | ExpectationManifestSchema,
|
| 8 | FactCheckResultSchema,
|
| 9 | FeedbackSchema,
|
| 10 | InteractionContractSchema,
|
| 11 | InteractionEventSchema,
|
| 12 | FederatedInteractionSchema,
|
| 13 | PublicAgentCardSchema,
|
| 14 | ReceiptSchema,
|
| 15 | RiskDecisionSchema,
|
| 16 | TrustEnvelopeSchema,
|
| 17 | } from '@openclasp/protocol';
|
| 18 |
|
| 19 | const schemas = {
|
| 20 | agent_identity: AgentIdentitySchema,
|
| 21 | delegation_credential: DelegationCredentialSchema,
|
| 22 | expectation_manifest: ExpectationManifestSchema,
|
| 23 | interaction_contract: InteractionContractSchema,
|
| 24 | trust_envelope: TrustEnvelopeSchema,
|
| 25 | interaction_event: InteractionEventSchema,
|
| 26 | fact_check_result: FactCheckResultSchema,
|
| 27 | receipt: ReceiptSchema,
|
| 28 | feedback: FeedbackSchema,
|
| 29 | risk_decision: RiskDecisionSchema,
|
| 30 | agent_transport: AgentTransportSchema,
|
| 31 | public_agent_card: PublicAgentCardSchema,
|
| 32 | federated_interaction: FederatedInteractionSchema,
|
| 33 | };
|
| 34 | await mkdir('schemas/v0.1', { recursive: true });
|
| 35 | await Promise.all(
|
| 36 | Object.entries(schemas).map(([name, schema]) =>
|
| 37 | writeFile(
|
| 38 | `schemas/v0.1/${name}.schema.json`,
|
| 39 | `${JSON.stringify(z.toJSONSchema(schema, { target: 'draft-2020-12' }), null, 2)}\n`,
|
| 40 | ),
|
| 41 | ),
|
| 42 | );
|