MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / serialize

Function serialize

packages/kernel/ir/src/serialize.ts:9–43  ·  view source on GitHub ↗
(catalog: LiveCatalog)

Source from the content-addressed store, hash-verified

7}
8
9export function serialize(catalog: LiveCatalog): typeof SerializedCatalog.Type {
10 const defs: Record<string, JsonSchema> = {};
11
12 function schemaToRef(schema: Schema.Top | undefined): string | undefined {
13 if (!schema) return undefined;
14
15 const identifier = getSchemaIdentifier(schema);
16 const document = Schema.toJsonSchemaDocument(schema);
17 Object.assign(defs, document.definitions);
18
19 if (identifier) {
20 return identifier;
21 }
22
23 // Inline schema without an identifier — store under a generated key
24 const key = `__inline_${Object.keys(defs).length}`;
25 defs[key] = document.schema;
26 return key;
27 }
28
29 const tools = catalog.tools.map((tool) => ({
30 path: tool.path,
31 description: tool.description,
32 integrationId: tool.integrationId,
33 input: schemaToRef(tool.input),
34 output: schemaToRef(tool.output),
35 error: schemaToRef(tool.error),
36 }));
37
38 return {
39 version: "v4.1" as const,
40 types: defs as Record<string, unknown>,
41 tools,
42 };
43}
44
45export function deserializeToJsonSchema(serialized: typeof SerializedCatalog.Type): {
46 tools: ReadonlyArray<{

Callers

nothing calls this directly

Calls 1

schemaToRefFunction · 0.85

Tested by

no test coverage detected