TOpenCode (OpenCode Zen)

Fuente: source/classes/topencode.prg

TOpenCode usa la API de chat OpenCode Zen (https://opencode.ai/zen/v1/chat/completions) con Authorization: Bearer public. Sin clave API. Modelos gratuitos (hy3-free, mimo-v2.5-free, deepseek-v4-flash-free, etc.). SendAsync exige la VM Harbour MT (build_new.bat <sample> hb32 mt).

Transporte: hbcurl sobre un libcurl estático (Schannel): no hace falta distribuir libcurl.dll. Los fuentes de curl y los scripts de build están en 3rdparty/ (salidas: lib/libcurl_static*.{lib,a} para bcc32/bcc64/msvc32/msvc64/gcc).

Métodos

MétodoDescripción
New( cModel )Un handle curl por instancia (varios agentes en paralelo).
Send( cPrompt ) / SendWithSystem()Síncrono; si hay rate limit, prueba otro modelo free.
SendAsync() / SendWithSystemAsync()Vuelve al momento. Consultar IsRunning().
GetValue()Texto del asistente (UTF-8 → ACP).

Async escribe oc_<ms>_<seq>.json vía .part + rename: tres SendAsync() en el mismo tick no chocan.

Samples

cd samples\ai
build_new.bat opencode2 hb32 mt

Ejecutar desde samples\ai para encontrar libcurl.dll.

Véase también