Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dbf2c659d9 | |||
| 2b8062c55f | |||
| 2ed6b26dde | |||
| d8e9fd12f4 | |||
| 8ef3eb6bec | |||
| 027ad82db2 | |||
| 8fa9c4ba20 | |||
| 8ab8e3fd31 | |||
| 05d717744b | |||
| 9c7bde47dc | |||
| b0d0975f05 | |||
| 6f634ae432 | |||
| c0553459e1 | |||
| 908ce303f3 | |||
| fd208583fe | |||
| 3e29fc43ab | |||
| 979a5677d5 | |||
| 17b1aa0736 | |||
| f0c731d2db | |||
| e7e0f7d3e5 |
@@ -174,6 +174,28 @@ jobs:
|
|||||||
-lcurl -lssl -lcrypto -lpthread -lm -o /tmp/el_native_fs
|
-lcurl -lssl -lcrypto -lpthread -lm -o /tmp/el_native_fs
|
||||||
/tmp/el_native_fs
|
/tmp/el_native_fs
|
||||||
|
|
||||||
|
# Build epm binary using elb (epm lives at repo root, not inside lang/)
|
||||||
|
- name: Build epm
|
||||||
|
run: |
|
||||||
|
ABS_ELB="$(pwd)/dist/bin/elb"
|
||||||
|
ABS_ELC="$(pwd)/dist/platform/elc"
|
||||||
|
ABS_RUNTIME="$(pwd)/el-compiler/runtime"
|
||||||
|
ABS_OUT="$(pwd)/dist/bin"
|
||||||
|
(cd ../epm && "$ABS_ELB" --clean --elc="$ABS_ELC" --runtime="$ABS_RUNTIME" --out="$ABS_OUT")
|
||||||
|
chmod +x dist/bin/epm
|
||||||
|
echo "epm built"
|
||||||
|
|
||||||
|
# Build el-install binary using elb
|
||||||
|
- name: Build el-install
|
||||||
|
run: |
|
||||||
|
ABS_ELB="$(pwd)/dist/bin/elb"
|
||||||
|
ABS_ELC="$(pwd)/dist/platform/elc"
|
||||||
|
ABS_RUNTIME="$(pwd)/el-compiler/runtime"
|
||||||
|
ABS_OUT="$(pwd)/dist/bin"
|
||||||
|
(cd tools/install && "$ABS_ELB" --clean --elc="$ABS_ELC" --runtime="$ABS_RUNTIME" --out="$ABS_OUT")
|
||||||
|
chmod +x dist/bin/el-install
|
||||||
|
echo "el-install built"
|
||||||
|
|
||||||
# Publish only after merge (push event), not on PR validation runs
|
# Publish only after merge (push event), not on PR validation runs
|
||||||
- name: Publish El SDK to Artifact Registry (dev)
|
- name: Publish El SDK to Artifact Registry (dev)
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
|
|||||||
@@ -170,6 +170,42 @@ jobs:
|
|||||||
-lcurl -lssl -lcrypto -lpthread -lm -o /tmp/el_native_fs
|
-lcurl -lssl -lcrypto -lpthread -lm -o /tmp/el_native_fs
|
||||||
/tmp/el_native_fs
|
/tmp/el_native_fs
|
||||||
|
|
||||||
|
# Build elb (needed for epm and el-install builds below)
|
||||||
|
- name: Build elb
|
||||||
|
run: |
|
||||||
|
mkdir -p dist/bin
|
||||||
|
dist/platform/elc elb.el > dist/elb.c
|
||||||
|
gcc -O2 \
|
||||||
|
-I el-compiler/runtime \
|
||||||
|
dist/elb.c \
|
||||||
|
el-compiler/runtime/el_runtime.c \
|
||||||
|
-lcurl -lssl -lcrypto -lpthread -lm \
|
||||||
|
-o dist/bin/elb
|
||||||
|
chmod +x dist/bin/elb
|
||||||
|
echo "elb built"
|
||||||
|
|
||||||
|
# Build epm binary using elb (epm lives at repo root, not inside lang/)
|
||||||
|
- name: Build epm
|
||||||
|
run: |
|
||||||
|
ABS_ELB="$(pwd)/dist/bin/elb"
|
||||||
|
ABS_ELC="$(pwd)/dist/platform/elc"
|
||||||
|
ABS_RUNTIME="$(pwd)/el-compiler/runtime"
|
||||||
|
ABS_OUT="$(pwd)/dist/bin"
|
||||||
|
(cd ../epm && "$ABS_ELB" --clean --elc="$ABS_ELC" --runtime="$ABS_RUNTIME" --out="$ABS_OUT")
|
||||||
|
chmod +x dist/bin/epm
|
||||||
|
echo "epm built"
|
||||||
|
|
||||||
|
# Build el-install binary using elb
|
||||||
|
- name: Build el-install
|
||||||
|
run: |
|
||||||
|
ABS_ELB="$(pwd)/dist/bin/elb"
|
||||||
|
ABS_ELC="$(pwd)/dist/platform/elc"
|
||||||
|
ABS_RUNTIME="$(pwd)/el-compiler/runtime"
|
||||||
|
ABS_OUT="$(pwd)/dist/bin"
|
||||||
|
(cd tools/install && "$ABS_ELB" --clean --elc="$ABS_ELC" --runtime="$ABS_RUNTIME" --out="$ABS_OUT")
|
||||||
|
chmod +x dist/bin/el-install
|
||||||
|
echo "el-install built"
|
||||||
|
|
||||||
# Publish only after merge (push event), not on PR validation runs
|
# Publish only after merge (push event), not on PR validation runs
|
||||||
- name: Publish El SDK to Artifact Registry (stage)
|
- name: Publish El SDK to Artifact Registry (stage)
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ jobs:
|
|||||||
ABS_ELC="$(pwd)/dist/platform/elc"
|
ABS_ELC="$(pwd)/dist/platform/elc"
|
||||||
ABS_RUNTIME="$(pwd)/el-compiler/runtime"
|
ABS_RUNTIME="$(pwd)/el-compiler/runtime"
|
||||||
ABS_OUT="$(pwd)/dist/bin"
|
ABS_OUT="$(pwd)/dist/bin"
|
||||||
(cd ../epm && "$ABS_ELB" --elc="$ABS_ELC" --runtime="$ABS_RUNTIME" --out="$ABS_OUT")
|
(cd ../epm && "$ABS_ELB" --clean --elc="$ABS_ELC" --runtime="$ABS_RUNTIME" --out="$ABS_OUT")
|
||||||
chmod +x dist/bin/epm
|
chmod +x dist/bin/epm
|
||||||
echo "epm built"
|
echo "epm built"
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ jobs:
|
|||||||
ABS_ELC="$(pwd)/dist/platform/elc"
|
ABS_ELC="$(pwd)/dist/platform/elc"
|
||||||
ABS_RUNTIME="$(pwd)/el-compiler/runtime"
|
ABS_RUNTIME="$(pwd)/el-compiler/runtime"
|
||||||
ABS_OUT="$(pwd)/dist/bin"
|
ABS_OUT="$(pwd)/dist/bin"
|
||||||
(cd tools/install && "$ABS_ELB" --elc="$ABS_ELC" --runtime="$ABS_RUNTIME" --out="$ABS_OUT")
|
(cd tools/install && "$ABS_ELB" --clean --elc="$ABS_ELC" --runtime="$ABS_RUNTIME" --out="$ABS_OUT")
|
||||||
chmod +x dist/bin/el-install
|
chmod +x dist/bin/el-install
|
||||||
echo "el-install built"
|
echo "el-install built"
|
||||||
|
|
||||||
|
|||||||
@@ -3135,23 +3135,49 @@ static void jb_puts(JsonBuf* b, const char* s) {
|
|||||||
|
|
||||||
static void jb_emit_escaped(JsonBuf* b, const char* s) {
|
static void jb_emit_escaped(JsonBuf* b, const char* s) {
|
||||||
jb_putc(b, '"');
|
jb_putc(b, '"');
|
||||||
for (; *s; s++) {
|
const unsigned char* p = (const unsigned char*)s;
|
||||||
unsigned char c = (unsigned char)*s;
|
while (*p) {
|
||||||
|
unsigned char c = *p;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '"': jb_puts(b, "\\\""); break;
|
case '"': jb_puts(b, "\\\""); p++; break;
|
||||||
case '\\': jb_puts(b, "\\\\"); break;
|
case '\\': jb_puts(b, "\\\\"); p++; break;
|
||||||
case '\b': jb_puts(b, "\\b"); break;
|
case '\b': jb_puts(b, "\\b"); p++; break;
|
||||||
case '\f': jb_puts(b, "\\f"); break;
|
case '\f': jb_puts(b, "\\f"); p++; break;
|
||||||
case '\n': jb_puts(b, "\\n"); break;
|
case '\n': jb_puts(b, "\\n"); p++; break;
|
||||||
case '\r': jb_puts(b, "\\r"); break;
|
case '\r': jb_puts(b, "\\r"); p++; break;
|
||||||
case '\t': jb_puts(b, "\\t"); break;
|
case '\t': jb_puts(b, "\\t"); p++; break;
|
||||||
default:
|
default:
|
||||||
if (c < 0x20) {
|
if (c < 0x20) {
|
||||||
char tmp[8];
|
char tmp[8];
|
||||||
snprintf(tmp, sizeof(tmp), "\\u%04x", c);
|
snprintf(tmp, sizeof(tmp), "\\u%04x", c);
|
||||||
jb_puts(b, tmp);
|
jb_puts(b, tmp);
|
||||||
} else {
|
p++;
|
||||||
|
} else if (c < 0x80) {
|
||||||
jb_putc(b, (char)c);
|
jb_putc(b, (char)c);
|
||||||
|
p++;
|
||||||
|
} else {
|
||||||
|
/* Multi-byte UTF-8: validate sequence, pass through if valid,
|
||||||
|
* escape as \u00xx if the start byte is invalid/orphaned. */
|
||||||
|
int seq_len = 0;
|
||||||
|
if ((c & 0xE0) == 0xC0) seq_len = 2;
|
||||||
|
else if ((c & 0xF0) == 0xE0) seq_len = 3;
|
||||||
|
else if ((c & 0xF8) == 0xF0) seq_len = 4;
|
||||||
|
if (seq_len >= 2) {
|
||||||
|
int valid = 1;
|
||||||
|
for (int i = 1; i < seq_len; i++) {
|
||||||
|
if ((p[i] & 0xC0) != 0x80) { valid = 0; break; }
|
||||||
|
}
|
||||||
|
if (valid) {
|
||||||
|
for (int i = 0; i < seq_len; i++) jb_putc(b, (char)p[i]);
|
||||||
|
p += seq_len;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Invalid start byte or truncated sequence — escape it */
|
||||||
|
char tmp[8];
|
||||||
|
snprintf(tmp, sizeof(tmp), "\\u%04x", c);
|
||||||
|
jb_puts(b, tmp);
|
||||||
|
p++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -8447,7 +8473,7 @@ static el_val_t llm_provider_request(const char* url, const char* key,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static el_val_t llm_chain_call(const char* system_str, const char* user_str) {
|
static el_val_t llm_chain_call(const char* model_pref, const char* system_str, const char* user_str) {
|
||||||
char url_key[64], key_key[64], fmt_key[64], model_key[64];
|
char url_key[64], key_key[64], fmt_key[64], model_key[64];
|
||||||
for (int i = 0; i < LLM_MAX_PROVIDERS; i++) {
|
for (int i = 0; i < LLM_MAX_PROVIDERS; i++) {
|
||||||
snprintf(url_key, sizeof(url_key), "NEURON_LLM_%d_URL", i);
|
snprintf(url_key, sizeof(url_key), "NEURON_LLM_%d_URL", i);
|
||||||
@@ -8460,6 +8486,7 @@ static el_val_t llm_chain_call(const char* system_str, const char* user_str) {
|
|||||||
const char* fmt_s = getenv(fmt_key);
|
const char* fmt_s = getenv(fmt_key);
|
||||||
int fmt = (fmt_s && strcmp(fmt_s, "anthropic") == 0) ? 1 : 0;
|
int fmt = (fmt_s && strcmp(fmt_s, "anthropic") == 0) ? 1 : 0;
|
||||||
const char* model = getenv(model_key);
|
const char* model = getenv(model_key);
|
||||||
|
if (!model || !*model) model = model_pref; /* fall back to the caller-requested model */
|
||||||
fprintf(stderr, "[llm] trying provider %d (%s)\n", i, url);
|
fprintf(stderr, "[llm] trying provider %d (%s)\n", i, url);
|
||||||
el_val_t result = llm_provider_request(url, key, fmt, model, system_str, user_str);
|
el_val_t result = llm_provider_request(url, key, fmt, model, system_str, user_str);
|
||||||
const char* t = EL_CSTR(result);
|
const char* t = EL_CSTR(result);
|
||||||
@@ -8470,7 +8497,7 @@ static el_val_t llm_chain_call(const char* system_str, const char* user_str) {
|
|||||||
const char* api_key = getenv("ANTHROPIC_API_KEY");
|
const char* api_key = getenv("ANTHROPIC_API_KEY");
|
||||||
if (!api_key || !*api_key) return http_error_json("no LLM providers configured");
|
if (!api_key || !*api_key) return http_error_json("no LLM providers configured");
|
||||||
fprintf(stderr, "[llm] using legacy ANTHROPIC_API_KEY fallback\n");
|
fprintf(stderr, "[llm] using legacy ANTHROPIC_API_KEY fallback\n");
|
||||||
return llm_provider_request(LLM_API_URL, api_key, 1, NULL, system_str, user_str);
|
return llm_provider_request(LLM_API_URL, api_key, 1, model_pref, system_str, user_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Legacy llm_request — kept for backward compat with agentic loop internals */
|
/* Legacy llm_request — kept for backward compat with agentic loop internals */
|
||||||
@@ -8534,14 +8561,16 @@ static el_val_t llm_extract_text(el_val_t resp_val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
el_val_t llm_call(el_val_t model, el_val_t prompt) {
|
el_val_t llm_call(el_val_t model, el_val_t prompt) {
|
||||||
|
const char* m = EL_CSTR(model);
|
||||||
const char* u = EL_CSTR(prompt); if (!u) u = "";
|
const char* u = EL_CSTR(prompt); if (!u) u = "";
|
||||||
return llm_chain_call(NULL, u);
|
return llm_chain_call(m, NULL, u);
|
||||||
}
|
}
|
||||||
|
|
||||||
el_val_t llm_call_system(el_val_t model, el_val_t system_prompt, el_val_t user_prompt) {
|
el_val_t llm_call_system(el_val_t model, el_val_t system_prompt, el_val_t user_prompt) {
|
||||||
|
const char* m = EL_CSTR(model);
|
||||||
const char* s = EL_CSTR(system_prompt); if (!s) s = "";
|
const char* s = EL_CSTR(system_prompt); if (!s) s = "";
|
||||||
const char* u = EL_CSTR(user_prompt); if (!u) u = "";
|
const char* u = EL_CSTR(user_prompt); if (!u) u = "";
|
||||||
return llm_chain_call(s, u);
|
return llm_chain_call(m, s, u);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ── Tool registry for llm_call_agentic ─────────────────────────────────── */
|
/* ── Tool registry for llm_call_agentic ─────────────────────────────────── */
|
||||||
|
|||||||
+5
-2
@@ -271,7 +271,10 @@ fn link_binary(c_files: [String], out_bin: String, runtime_path: String, out_dir
|
|||||||
let parts: [String] = native_list_empty()
|
let parts: [String] = native_list_empty()
|
||||||
// Include both the runtime dir (for el_runtime.h) and the output dir
|
// Include both the runtime dir (for el_runtime.h) and the output dir
|
||||||
// (for module.elh cross-module forward declarations).
|
// (for module.elh cross-module forward declarations).
|
||||||
let parts = native_list_append(parts, "cc -O2 -fbracket-depth=1024 -I " + dirname_of(runtime_path) + " -I " + out_dir)
|
// Detect clang vs gcc: -fbracket-depth is clang-only; silently ignored
|
||||||
|
// if unsupported but gcc rejects it with an error.
|
||||||
|
let bracket_flag: String = "$(cc --version 2>&1 | grep -q clang && printf -- '-fbracket-depth=1024' || true)"
|
||||||
|
let parts = native_list_append(parts, "cc -O2 " + bracket_flag + " -I " + dirname_of(runtime_path) + " -I " + out_dir)
|
||||||
let i = 0
|
let i = 0
|
||||||
while i < n {
|
while i < n {
|
||||||
let f: String = native_list_get(c_files, i)
|
let f: String = native_list_get(c_files, i)
|
||||||
@@ -279,7 +282,7 @@ fn link_binary(c_files: [String], out_bin: String, runtime_path: String, out_dir
|
|||||||
let i = i + 1
|
let i = i + 1
|
||||||
}
|
}
|
||||||
let parts = native_list_append(parts, runtime_path)
|
let parts = native_list_append(parts, runtime_path)
|
||||||
let parts = native_list_append(parts, "-lcurl -lpthread -lm")
|
let parts = native_list_append(parts, "-lcurl -lssl -lcrypto -lpthread -lm")
|
||||||
let parts = native_list_append(parts, "-o " + out_bin)
|
let parts = native_list_append(parts, "-o " + out_bin)
|
||||||
let cmd: String = str_join(parts, " ")
|
let cmd: String = str_join(parts, " ")
|
||||||
println(" link " + out_bin)
|
println(" link " + out_bin)
|
||||||
|
|||||||
@@ -10,15 +10,6 @@
|
|||||||
// export PATH="$HOME/.el/bin:$PATH"
|
// export PATH="$HOME/.el/bin:$PATH"
|
||||||
// export EL_HOME="$HOME/.el"
|
// export EL_HOME="$HOME/.el"
|
||||||
|
|
||||||
// ── Imports ───────────────────────────────────────────────────────────────────
|
|
||||||
|
|
||||||
import "../../runtime/string.el"
|
|
||||||
import "../../runtime/env.el"
|
|
||||||
import "../../runtime/fs.el"
|
|
||||||
import "../../runtime/exec.el"
|
|
||||||
import "../../runtime/json.el"
|
|
||||||
import "../../runtime/http.el"
|
|
||||||
|
|
||||||
// ── Constants ─────────────────────────────────────────────────────────────────
|
// ── Constants ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
fn gitea_releases_url() -> String {
|
fn gitea_releases_url() -> String {
|
||||||
|
|||||||
Reference in New Issue
Block a user