| 1 | import { mkdir, writeFile } from 'node:fs/promises';
|
| 2 | import { z } from 'zod';
|
| 3 | import {
|
| 4 | AgentIdentitySchema,
|
| 5 | AgentPresenceSchema,
|
| 6 | AgentModeSchema,
|
| 7 | AgentTransportSchema,
|
| 8 | DelegationCredentialSchema,
|
| 9 | ExpectationManifestSchema,
|
| 10 | FactCheckResultSchema,
|
| 11 | FeedbackSchema,
|
| 12 | InteractionContractSchema,
|
| 13 | InteractionEventSchema,
|
| 14 | FederatedInteractionSchema,
|
| 15 | LiveSessionAcceptanceSchema,
|
| 16 | LiveSessionActivationSchema,
|
| 17 | LiveSessionEventSchema,
|
| 18 | LiveSessionOfferSchema,
|
| 19 | HostedMessageSchema,
|
| 20 | HostedThreadSchema,
|
| 21 | PublicAgentCardSchema,
|
| 22 | ReceiptSchema,
|
| 23 | RiskDecisionSchema,
|
| 24 | TrustEnvelopeSchema,
|
| 25 | } from '@openclasp/protocol';
|
| 26 |
|
| 27 | const schemas = {
|
| 28 | agent_identity: AgentIdentitySchema,
|
| 29 | delegation_credential: DelegationCredentialSchema,
|
| 30 | expectation_manifest: ExpectationManifestSchema,
|
| 31 | interaction_contract: InteractionContractSchema,
|
| 32 | trust_envelope: TrustEnvelopeSchema,
|
| 33 | interaction_event: InteractionEventSchema,
|
| 34 | fact_check_result: FactCheckResultSchema,
|
| 35 | receipt: ReceiptSchema,
|
| 36 | feedback: FeedbackSchema,
|
| 37 | risk_decision: RiskDecisionSchema,
|
| 38 | agent_transport: AgentTransportSchema,
|
| 39 | agent_presence: AgentPresenceSchema,
|
| 40 | agent_mode: AgentModeSchema,
|
| 41 | public_agent_card: PublicAgentCardSchema,
|
| 42 | federated_interaction: FederatedInteractionSchema,
|
| 43 | live_session_offer: LiveSessionOfferSchema,
|
| 44 | live_session_acceptance: LiveSessionAcceptanceSchema,
|
| 45 | live_session_activation: LiveSessionActivationSchema,
|
| 46 | live_session_event: LiveSessionEventSchema,
|
| 47 | hosted_message: HostedMessageSchema,
|
| 48 | hosted_thread: HostedThreadSchema,
|
| 49 | };
|
| 50 | await mkdir('schemas/v0.1', { recursive: true });
|
| 51 | await Promise.all(
|
| 52 | Object.entries(schemas).map(([name, schema]) =>
|
| 53 | writeFile(
|
| 54 | `schemas/v0.1/${name}.schema.json`,
|
| 55 | `${JSON.stringify(z.toJSONSchema(schema, { target: 'draft-2020-12' }), null, 2)}\n`,
|
| 56 | ),
|
| 57 | ),
|
| 58 | );
|