The AI trust layer between agents: identity, agreements, safeguards, and outcome intelligence for A2A.

Commit 2a4cc60d

2a4cc60d2506Merged

aryaamin <[email protected]> · 2 months ago · 2 files · ~2 modified

Description

fix: compose refined MCP event schema safely

Details

Commit
2a4cc60d2506
Parent
cd4450c423f7

packages/mcp-server/src/server.tsmodifiedView file

@@ -90,6 +90,34 @@
9090 content: [{ type: 'text' as const, text: JSON.stringify(value, null, 2) }],
9191 });
9292
93+const LiveSessionEventInputSchema = z
94+ .object({
95+ interactionId: LiveSessionEventSchema.shape.interactionId,
96+ sequence: LiveSessionEventSchema.shape.sequence,
97+ type: LiveSessionEventSchema.shape.type,
98+ occurredAt: LiveSessionEventSchema.shape.occurredAt,
99+ messageHash: LiveSessionEventSchema.shape.messageHash,
100+ evidenceReferences: LiveSessionEventSchema.shape.evidenceReferences,
101+ outcome: LiveSessionEventSchema.shape.outcome,
102+ checkpoint: LiveSessionEventSchema.shape.checkpoint,
103+ details: LiveSessionEventSchema.shape.details,
104+ })
105+ .strict()
106+ .superRefine((event, context) => {
107+ if (event.type === 'progress_checkpoint' && !event.checkpoint)
108+ context.addIssue({
109+ code: 'custom',
110+ path: ['checkpoint'],
111+ message: 'Progress checkpoint events require structured checkpoint data',
112+ });
113+ if (event.type !== 'progress_checkpoint' && event.checkpoint)
114+ context.addIssue({
115+ code: 'custom',
116+ path: ['checkpoint'],
117+ message: 'Checkpoint data is only valid on progress checkpoint events',
118+ });
119+ });
120+
93121 export const OPENCLASP_MCP_INSTRUCTIONS =
94122 'Start with openclasp_connection_status and heartbeat while active. Persistent runtimes use direct A2A; temporary agents use hosted thread tools. For longer tasks, call openclasp_checkpoint about every five meaningful exchanges or when blocked, drifting, or nearly done. At a terminal outcome call openclasp_complete_live_session with an honest assessment and feedback; it triggers peer finalization. Submit structured evidence only; never upload transcripts or invent feedback.';
95123
@@ -1084,7 +1112,7 @@
10841112 title: 'Record structured session event',
10851113 description:
10861114 'Record signed session metadata, hashes, evidence, corrections, or results without uploading raw messages.',
1087- inputSchema: LiveSessionEventSchema.omit({ eventId: true, agentId: true }),
1115+ inputSchema: LiveSessionEventInputSchema,
10881116 annotations: WRITE_TOOL,
10891117 },
10901118 async (input, context) => {