CliSubprocessCore.OutputSchemaFile (CliSubprocessCore v0.4.1)

Copy Markdown View Source

Materializes a structured-output JSON Schema onto disk for provider CLIs that take the schema as a file path.

codex exec types --output-schema as a path and exits non-zero when it cannot read the file, so passing the schema inline is not a degraded mode — it is a hard failure. This module owns the file's whole life: creation, the path handed to argv, and removal.

Removal is guaranteed by CliSubprocessCore.EphemeralFiles, which monitors the process that asked for the file. The returned cleanup function is the ordinary path; the monitor covers the case where the owner never gets to run it.

Summary

Functions

Writes schema to a temporary JSON file owned by owner.

Types

cleanup()

@type cleanup() :: (-> :ok)

Functions

create(schema, owner \\ self())

@spec create(term(), pid()) :: {:ok, String.t() | nil, cleanup()} | {:error, term()}

Writes schema to a temporary JSON file owned by owner.

Returns {:ok, nil, cleanup} for a nil schema so callers can use one shape unconditionally. Fails closed: if the file cannot be written, or if no owner can guarantee its removal, no file is left behind and no path is returned.