Índice de builtins
Un mapa categorizado de los builtins. Las firmas completas viven en cada página de tema; los centrales están doctested acá para que esta referencia no driftee.
-- Doc reference: a few core builtins, doctested so the reference can't drift.
intent: "doc reference: core builtins"
print("upper(\"hi\") = " + upper("hi") + ", join([a,b],\"-\") = " + join(["a", "b"], "-"))
test "collections"
assert_eq(length([1, 2, 3]), 3)
assert(contains([1, 2, 3], 2))
assert_eq(slice([1, 2, 3, 4], 1, 3), [2, 3]) -- Python-style end-exclusive
assert_eq(keys({"a": 1, "b": 2}), ["a", "b"])
assert_eq(values({"a": 1, "b": 2}), [1, 2])
test "text"
assert_eq(upper("hi"), "HI")
assert_eq(trim(" x "), "x")
assert_eq(split("a,b,c", ","), ["a", "b", "c"])
assert_eq(join(["a", "b"], "-"), "a-b")
assert(starts_with("hello", "he"))
test "intentional ops"
assert_eq(apply((n) => n * 2, [1, 2, 3]), [2, 4, 6])
assert_eq(where([1, 2, 3, 4], (n) => n > 2), [3, 4])
assert_eq(reduce([1, 2, 3], (a, b) => a + b, 0), 6)
test "intentional ops accept both orders (fn-first and list-first)"
assert_eq(apply([1, 2, 3], (n) => n * 2), [2, 4, 6]) -- list-first also works
assert_eq(where((n) => n > 2, [1, 2, 3, 4]), [3, 4]) -- fn-first also works
assert_eq(reduce((a, b) => a + b, [1, 2, 3], 10), 16) -- extra args stay at the end
test "unique and index_of"
assert_eq(unique([3, 1, 3, 2, 1]), [3, 1, 2]) -- first-appearance order
assert_eq(index_of([10, 20, 30], 20), 1) -- by item
assert_eq(index_of([1, 2, 3], (n) => n > 1), 1) -- by predicate
assert_eq(index_of([1, 2], 9), nothing) -- absent → nothing, not -1
Por categoría
- Colecciones:
length,contains,slice,keys,values,apply,where,reduce,sort_by,group_by,find_first,every,some,collect,count_where,flatten,chunk,zip_with,unique(dedupe, orden de primera aparición, igualdad estructural),index_of(índice base 0 por item o predicado; ausente →nothing, no -1). Los ops intencionales que toman un callable aceptan ambos órdenes —apply(fn, lista)yapply(lista, fn)se leen igual de bien; dos tasks o dos listas donde se esperaba una-y-una es error explícito. - Texto:
upper,lower,fold,trim,starts_with,split,join,replace_text,replace_re,matches,capture,text,fmt. - Números / matemática:
+ - / % *,number, constantespi/tau/e/inf/nan; arraysarray,dot,norm,matmul,solve,det,inv,eig,svd. - Bytes / cripto:
bytes,decode(encodings:utf8,hex,base64,base64url,base58,base32),sha256,sha512,hmac_sha256,verify_hmac,constant_time_eq. - Web auth (engine v0.5.5+ — ver Login y sesiones):
password_hash,password_verify,jwt_sign,jwt_verify,totp,totp_verify(puros);random_bytes,token(require random); respuestaswith_header,set_cookie,clear_cookie;request.cookies; auth task de 2 parámetros. - Identidad de agentes y auth (engine v0.5.6+ — ver Identidad de agentes): tokens de capacidad
captoken_mint,captoken_attenuate(offline, sin clave),captoken_verify,captoken_allows(puros); requests firmadashttp_sign(require sign("CLAVE")+ auditoría) yhttp_signature_verify(puro,opts.algobligatorio); OIDC de tercerosoidc_verify(iss+audobligatorios; el JWKS necesitarequire net(host));mtls_identity(cert, key, opts?)con alcance poropts.hosts(require file.read); medición por identidad:spend_total(unidad, identidad?), rate limits por identidad ySYNSEMA_SPEND_CEILING_PER_IDENTITY="agente=UNIDAD:tope"(cualquier unidad — ninguna moneda privilegiada); descubrimiento en/.well-known/synsema-auth. - Tiempo / random:
now,format_time,parse_time,sleep,random,random_int(random,random_bytesytokennecesitanrequire random). - JSON:
json_encode,json_decode. - CSV:
csv_parse,csv_encode. - Estadística:
median,percentile,histogram(tambiénsum,mean,std,var). - Gráficos:
chart_svg;chart(nodo de contenido negociado). - I/O (gateado por capacidad):
read_file,write_file,append_file,edit_file,file_exists,file_info,list_dir,grep,read_file_bytes. - HTTP:
http,http_get,http_post,http_put,http_delete,fetch. - WebSocket:
ws_connect,ws_send,ws_recv,ws_close, más multiplexado/resilienciaws_select,ws_select_all,ws_broadcast,ws_status,ws_stats(todos gateados pornet). Opts dews_connect:subprotocols,max_queue,max_queue_bytes,on_full,reconnect({max_retries, backoff, backoff_max, on_reconnect}),keepalive({interval, timeout}). - Blockchain (puros):
keccak256,sha512_256,secp256k1_verify/recover/pubkey,ed25519_verify/pubkey,eth_address,rlp_encode/decode,abi_encode/decode/selector,eip191_digest,eip712_digest,solana_message/tx,solana_pda,spl_ata,spl_transfer_data,spl_transfer_checked_data,algorand_tx_encode/tx,algo_address,bytes_to_int,int_to_bytes,int_to_bytes_le. - Blockchain (gateados):
secp256k1_sign/ed25519_sign/schnorr_sign(require sign);mnemonic_generate,mnemonic_to_seed,hd_derive,algorand_mnemonic,keystore_import/keystore_export,wif_import(require wallet). - Bitcoin (puros):
hash160,btc_address,btc_address_decode,btc_script,btc_txid,schnorr_verify,schnorr_pubkey,btc_tx,btc_tx_raw,psbt_encode,psbt_decode,psbt_finalize. - Bitcoin (lado de lectura, gateado por
net):btc_utxos,btc_balance,btc_fee_estimates,btc_send,btc_wait,btc_rpc. - Lado de lectura de blockchain (gateado por
net, como HTTP):eth_rpc,eth_nonce,eth_balance,eth_gas_price,eth_chain_id,eth_estimate_gas,eth_call,eth_fee_history,eth_send_raw,eth_receipt,eth_wait_receipt;solana_rpc,solana_latest_blockhash,solana_balance,solana_send,solana_confirm,spl_balance;algorand_params,algorand_account,algorand_send,algorand_wait. Más los builders purostx_eip1559/tx_eip1559_raw. - DB:
db_open,sql,sql_exec,sql_batch,sql_tables,paged;mongo_;redis_. - Cron:
cron_every,cron_after,cron_cancel,cron_list,cron_status. - LLM / tools:
llm_available,llm_usage(tokens consumidos por este proceso;0offline — ver Primitivas LLM),llm_step,call,call_tool. - Dinero / ledger de gasto (
require spend("UNIDAD")— ver Capacidades):spend(monto, unidad, motivo)→ total acumulado de la unidad (auditado enspend.log, techo del hostSYNSEMA_SPEND_CEILING);spend_total(unidad)→ total del proceso, sin capability. - Memoria / progreso / reglas (toda la familia necesita
require memory("name")— ver Memoria y estado):remember,recall,forget_memory,memory_summary,create_progress,start_step,complete_step,fail_step,resume_point,progress_display,progress_percent,add_rule,check_rules,get_rules. - Secretos:
secret,as_secret,bearer,reveal. - Respuestas (serve):
ok,created,fail,not_found,respond,redirect,render,content,paged. - Errores:
raise,assert,assert_eq,assert_ne,assert_error.