la-machina-engine 0.7.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -7866,6 +7866,9 @@ async function collectSkills(storage, skillsDir) {
7866
7866
  // src/engine/jsonOutput.ts
7867
7867
  init_cjs_shims();
7868
7868
  var import_zod_to_json_schema2 = require("zod-to-json-schema");
7869
+ function isZodSchema(s) {
7870
+ return s !== null && typeof s === "object" && "_def" in s && typeof s.safeParse === "function";
7871
+ }
7869
7872
  function buildSchemaPrompt(schema) {
7870
7873
  const lines = [
7871
7874
  "# Output Format",
@@ -7875,11 +7878,18 @@ function buildSchemaPrompt(schema) {
7875
7878
  "Do NOT wrap in ```json ... ```. Just raw JSON."
7876
7879
  ];
7877
7880
  if (schema) {
7878
- const jsonSchema2 = (0, import_zod_to_json_schema2.zodToJsonSchema)(schema, {
7879
- target: "jsonSchema7",
7880
- $refStrategy: "none"
7881
- });
7882
- const { $schema: _, ...clean } = jsonSchema2;
7881
+ let clean;
7882
+ if (isZodSchema(schema)) {
7883
+ const jsonSchema2 = (0, import_zod_to_json_schema2.zodToJsonSchema)(schema, {
7884
+ target: "jsonSchema7",
7885
+ $refStrategy: "none"
7886
+ });
7887
+ const { $schema: _z, ...rest } = jsonSchema2;
7888
+ clean = rest;
7889
+ } else {
7890
+ const { $schema: _j, ...rest } = schema;
7891
+ clean = rest;
7892
+ }
7883
7893
  lines.push("", "The JSON MUST conform to this schema:", JSON.stringify(clean, null, 2));
7884
7894
  } else {
7885
7895
  lines.push("", "Return a JSON object with the relevant data.");
@@ -7915,6 +7925,9 @@ function tryParseJSON2(text2) {
7915
7925
  return { ok: false, error: "No valid JSON found in response" };
7916
7926
  }
7917
7927
  function validateOutput(value, schema) {
7928
+ if (!isZodSchema(schema)) {
7929
+ return { ok: true, data: value };
7930
+ }
7918
7931
  const result = schema.safeParse(value);
7919
7932
  if (result.success) {
7920
7933
  return { ok: true, data: result.data };