Skip to content

Generate (or, with `current`, refine) a TypeScript handler from English, with the tsc verdict

POST
/api/v1/admin/handlers/generate
curl --request POST \
--url http://localhost:11044/api/v1/admin/handlers/generate \
--header 'Content-Type: application/json' \
--header 'X-Embabel-Api-Key: <X-Embabel-Api-Key>' \
--data '{ "current": "example", "english": "example", "skills": [ "example" ] }'

english describes the handler to write; when current is given, english is instead a change to make to that source. skills names skills handed to the writing model as references, prompt and tools both. Nothing is saved: the answer is the source with its tsc verdict

Media typeapplication/json

An English description of a handler, optionally as a change to existing source.

object
current

When present, english is a CHANGE to this source — the round-trip an editor’s Refine drives.

string
english
required

What the handler should do, in English; with current, the change to make to that source.

string
skills

Skills to bundle. They are handed to the writing model as references — prompt contribution AND tools — so a realm’s documented idioms are followed rather than re-derived.

Array<string>

Example generated

{
"current": "example",
"english": "example",
"skills": [
"example"
]
}

The generated source and whether it type-checks

Media typeapplication/json

Generated (or refined) handler source, with the tsc verdict on it.

object
attempts
required

1, or 2 when the model was handed its own type errors to fix.

integer format: int32
durationMs
required

Server-side time the generation took, attempts included, in milliseconds.

integer format: int64
ok
required

Always true; valid carries the verdict.

boolean
source
required

The generated TypeScript handler body. Nothing is saved.

string
valid
required

Whether source passes the same tsc gate save enforces.

boolean
violations
required

The compiler’s errors, in the SOURCE’s own line coordinates. Empty when valid.

Array<string>

Example generated

{
"attempts": 1,
"durationMs": 1,
"ok": true,
"source": "example",
"valid": true,
"violations": [
"example"
]
}

No authenticated principal

Media typeapplication/json

A refusal carrying only a human-readable reason.

object
error
required

What went wrong, in the terms the caller can act on.

string

Example generated

{
"error": "example"
}