{"version":3,"file":"standard_schema.cjs","names":[],"sources":["../../src/utils/standard_schema.ts"],"sourcesContent":["import { StandardJSONSchemaV1, StandardSchemaV1 } from \"@standard-schema/spec\";\n\n/**\n * A schema that supports both runtime validation and JSON Schema generation. Any schema passed\n * to withStructuredOutput must satisfy both interfaces.\n */\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport type SerializableSchema<Input = any, Output = Input> = StandardSchemaV1<\n  Input,\n  Output\n> &\n  StandardJSONSchemaV1<Input, Output>;\n\n/**\n * Type guard for Standard Schema V1. Returns true if the value has a `~standard.validate`\n * interface, indicating it can validate unknown values at runtime (e.g. for parsing LLM output).\n */\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isStandardSchema<Input = any, Output = Input>(\n  schema: unknown\n): schema is StandardSchemaV1<Input, Output> {\n  return (\n    (typeof schema === \"object\" || typeof schema === \"function\") &&\n    schema !== null &&\n    \"~standard\" in schema &&\n    typeof schema[\"~standard\"] === \"object\" &&\n    schema[\"~standard\"] !== null &&\n    \"validate\" in schema[\"~standard\"]\n  );\n}\n\n/**\n * Type guard for Standard JSON Schema V1. Returns true if the value has a `~standard.jsonSchema`\n * interface, indicating it can be converted to a JSON Schema object (e.g. for sending as a tool\n * definition to an LLM).\n */\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isStandardJsonSchema<Input = any, Output = Input>(\n  schema: unknown\n): schema is StandardJSONSchemaV1<Input, Output> {\n  return (\n    (typeof schema === \"object\" || typeof schema === \"function\") &&\n    schema !== null &&\n    \"~standard\" in schema &&\n    typeof schema[\"~standard\"] === \"object\" &&\n    schema[\"~standard\"] !== null &&\n    \"jsonSchema\" in schema[\"~standard\"]\n  );\n}\n\n/**\n * Type guard for Standard Schema V1. Returns true if the value has a `~standard.validate` interface,\n * indicating it can validate unknown values at runtime (e.g. for parsing LLM output).\n */\n// oxlint-disable-next-line @typescript-eslint/no-explicit-any\nexport function isSerializableSchema<Input = any, Output = Input>(\n  schema: unknown\n): schema is SerializableSchema<Input, Output> {\n  return isStandardSchema(schema) && isStandardJsonSchema(schema);\n}\n"],"mappings":";;;;;;;;;;;AAkBA,SAAgB,iBACd,QAC2C;AAC3C,SACG,OAAO,WAAW,YAAY,OAAO,WAAW,eACjD,WAAW,QACX,eAAe,UACf,OAAO,OAAO,iBAAiB,YAC/B,OAAO,iBAAiB,QACxB,cAAc,OAAO;;;;;;;AAUzB,SAAgB,qBACd,QAC+C;AAC/C,SACG,OAAO,WAAW,YAAY,OAAO,WAAW,eACjD,WAAW,QACX,eAAe,UACf,OAAO,OAAO,iBAAiB,YAC/B,OAAO,iBAAiB,QACxB,gBAAgB,OAAO;;;;;;AAS3B,SAAgB,qBACd,QAC6C;AAC7C,QAAO,iBAAiB,OAAO,IAAI,qBAAqB,OAAO"}