Something went wrong. Try again.
A local-first event pipeline for independent agents, built on Jazz.
Something went wrong. Try again.
2.3 kB · 54 lines
TypeScript
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455import { z } from "zod";import { PUBLIC_KNOWLEDGE_PROPOSED_DIFF_OUTPUT_CONTRACT, publicKnowledgeProposedDiffOutputSchema,} from "../agents/output-contracts.js";import type { JsonObject, JsonValue } from "../core/json.js";
export const PUBLIC_KNOWLEDGE_PROPOSED_DIFF_EVENT_TYPE = "stream.thought.agent.public-knowledge-diff.proposed";export const PUBLIC_KNOWLEDGE_PROPOSED_DIFF_SCHEMA_VERSION = 1;
const jsonValueSchema: z.ZodType<JsonValue> = z.lazy(() => z.union([ z.string(), z.number(), z.boolean(), z.null(), z.array(jsonValueSchema), z.record(z.string(), jsonValueSchema),]));const objectPayload = z.record(z.string(), jsonValueSchema) as z.ZodType<JsonObject>;const outputContractIdentitySchema = z.object({ id: z.string().min(1), version: z.number().int().positive(), sha256: z.string().regex(/^[a-f0-9]{64}$/),}).strict();
export const publicKnowledgeProposedDiffPayloadSchema = z.object({ runId: z.string().min(1), executionKey: z.string().min(1), inputEventId: z.string().min(1), inputSourceSequence: z.number().int().positive(), summary: z.string().min(1).max(1_600), confidence: z.enum(["low", "medium", "high"]), outputContract: outputContractIdentitySchema, structuredOutput: publicKnowledgeProposedDiffOutputSchema, model: objectPayload.optional(), executionAdapterRevision: z.string().min(1).max(500).optional(),}).strict().superRefine((value, context) => { const expected = PUBLIC_KNOWLEDGE_PROPOSED_DIFF_OUTPUT_CONTRACT.identity; if (value.outputContract.id !== expected.id || value.outputContract.version !== expected.version || value.outputContract.sha256 !== expected.sha256) { context.addIssue({ code: "custom", path: ["outputContract"], message: "Proposal must name the canonical Public Knowledge proposed-diff contract", }); } if (value.summary !== value.structuredOutput.summary) { context.addIssue({ code: "custom", path: ["summary"], message: "Summary must equal canonical structured output" }); } if (value.confidence !== value.structuredOutput.confidence) { context.addIssue({ code: "custom", path: ["confidence"], message: "Confidence must equal canonical structured output" }); }}) as unknown as z.ZodType<JsonObject>;