XU XUv0.16.0

Official External Packages

The Xu 0.16.0 SDK bundles the 1.0.2 drivers and their native source resources. The standalone 1.17.0 source adds the AI and GPU packages described below. Check the source version on each API page when selecting a dependency.

1. Select the SDK bundle or a fixed source commit

Place your project beside the extracted SDK and declare its bundled packages using a local source locator. Adjust the relative path if you installed the SDK elsewhere:

module: my_app
version: !ver 0.1.0
xu: !ver 0.16.0
require:
  "github.com/xulang-org/packages": file:../xu-v0.16.0/packages

To fetch the source used by this SDK instead, select its full immutable commit:

require:
  "github.com/xulang-org/packages": git:https://github.com/xulang-org/packages.git@c16af7ca38dc31c289ca83670edf153f1f85f5f2

From your project directory, resolve and lock dependencies, then check and build:

xu install
xu check main.xu --offline
xu build main.xu -o my_app

Module versions and Git tags have separate roles: this bundle declares module version 1.0.2. The fixed source locator above selects the exact source independently of tag availability. Keep xu.lock with your application and consult modules and dependencies for frozen, vendor and proxy workflows.

2. Importing Packages in Source Code

Xu enforces an explicit namespace alias convention for all external packages: alias #full/module/path/pkg. This eliminates global namespace pollution and makes all external dependencies visible directly at the top of the file.

@main

// 1. Standard library modules have no alias; prefixed with #
#database/sql

// 2. External packages declare an alias and full repository path
mysql    #github.com/xulang-org/packages/mysql
redis    #github.com/xulang-org/packages/redis
postgres #github.com/xulang-org/packages/postgres

fn main() int {
    // Access APIs directly through the declared alias
    println("Drivers loaded successfully")
    << 0
}

Important: Do not write #mysql or #redis. External module imports require an explicit alias and full module path. Standard library imports and local package imports (such as #util) follow their own resolution rules. The integrations listed here belong to github.com/xulang-org/packages; other external modules have their own identities.

3. Hands-on Quickstart Examples

Example 1: Using the MySQL Driver with database/sql

The standard library database/sql provides connection pooling, transactions, and result row abstractions; the concrete MySQL driver is implemented by packages/mysql:

@main
#database/sql
mysql #github.com/xulang-org/packages/mysql

fn main() int {
    dsn := "root:123456@tcp(127.0.0.1:3306)/test_db?tls=false"
    $db := sql.open(mysql.driver(), dsn)
    db.ping() >>> (err) {
        println("Database ping failed: " + err.msg())
        << 1
    }
    println("Connected to MySQL successfully!")
    db.close() >>> (err) { << 1 }
    << 0
}

Example 2: Redis Client Operations

@main
redis #github.com/xulang-org/packages/redis

fn main() int {
    $client := redis.open("127.0.0.1:6379") >>> (err) {
        println("Redis connect error: " + err.msg())
        << 1
    }
    client.set("app_version", "demo") >>> (err) { << 1 }
    val := client.get("app_version") >>> (err) { << 1 }
    println("Key 'app_version': " + val)
    client.close()
    << 0
}

Example 3: Object Storage with S3 / MinIO

@main
s3 #github.com/xulang-org/packages/s3

fn main() int {
    $client := s3.open("http://127.0.0.1:9000", "access_key", "secret_key", "us-east-1")
    client.put_object("my-bucket", "welcome.txt", "Hello from Xu!", "text/plain") >>> (err) {
        println("S3 upload failed: " + err.msg())
        << 1
    }
    println("Object uploaded successfully")
    << 0
}

4. Package Catalog & One-Line Import Snippets

The catalog covers 30 packages bundled with the SDK, including the shared transport package, and 17 AI and GPU packages from the standalone module. You can copy-paste the exact import snippet into your code:

The status columns describe source paths in the SDK bundle and standalone module, including client.xu, authentication files, tls.xu helpers and transport/mod.xu. They are source evidence, not service interoperability or platform acceptance results. unknown means the capability has not been proven here.

TLS paths: HTTPS business requests use the shared TLS connection path; their legacy manual fd pools remain plaintext. A TLS byte-stream helper only provides tls_connect / tls_connect_config and raw reads / writes; it does not establish that the package’s ordinary authenticated client or pool runs over TLS. That integration is explicitly unknown. SMTP STARTTLS and DNS-over-TLS query integration are unknown. The default TLS configuration verifies certificates and hostnames; these source paths have not been exercised against every service here.

Platform: Network drivers use native sockets and are local SDK paths, outside the browser playground subset. Per-OS / architecture acceptance is unknown for every row. SQLite now uses pure Xu sqlite_native dynamic loading, without requiring static .xulib slices. See download boundaries and status.

Category Package Service One-Line Import Snippet API Reference Protocol scope Authentication TLS path Platform / acceptance
DatabasesmysqlMySQL / MariaDBmysql #github.com/xulang-org/packages/mysqlAPI ReferenceMySQL text protocolmysql_native_password; caching_sha2_password rejectedDSN TLS upgrade with certificate / hostname checksNative sockets; acceptance unknown
DatabasespostgresPostgreSQLpostgres #github.com/xulang-org/packages/postgresAPI ReferencePostgreSQL wire 3.0Trust / cleartext / MD5 / SCRAM-SHA-256SSLRequest upgrade; require / verify-ca / verify-fullNative sockets; acceptance unknown
DatabasessqliteSQLite Embeddedsqlite #github.com/xulang-org/packages/sqliteAPI ReferenceEmbedded SQLite C APINot applicable (embedded)Not applicable (no network transport)Pure Xu dynamic loading; no .xulib; target acceptance unknown
DatabasesclickhouseClickHouse Columnarclickhouse #github.com/xulang-org/packages/clickhouseAPI ReferenceHTTP SQL requestsX-ClickHouse-User / Key headersHTTPS request path; fd pools remain plaintextNative sockets; acceptance unknown
DatabasesmongodbMongoDB Document DBmongodb #github.com/xulang-org/packages/mongodbAPI ReferenceOP_MSG subset; no compression / topology discoveryunknownTLS byte-stream helper; client TLS unknownNative sockets; acceptance unknown
DatabasescassandraApache Cassandracassandra #github.com/xulang-org/packages/cassandraAPI ReferenceCQL binary v4; startup / queriesunknownTLS byte-stream helper; client TLS unknownNative sockets; acceptance unknown
Databasesneo4jNeo4j Graph Databaseneo4j #github.com/xulang-org/packages/neo4jAPI ReferenceHTTP Cypher transactions; no Bolt claimHTTP BasicHTTPS request path; fd pools remain plaintextNative sockets; acceptance unknown
CachesredisRedis High-Speed Cacheredis #github.com/xulang-org/packages/redisAPI ReferenceRESP2 and bounded RESP3 typesPassword AUTH; ACL username support unknownTLS byte-stream helper; client TLS unknownNative sockets; acceptance unknown
CachesmemcachedMemcachedmemcached #github.com/xulang-org/packages/memcachedAPI ReferenceText commandsunknownTLS byte-stream helper; client TLS unknownNative sockets; acceptance unknown
MessagingkafkaApache Kafkakafka #github.com/xulang-org/packages/kafkaAPI ReferenceProduce v3 / Fetch v4 subset; uncompressed recordsunknownTLS byte-stream helper; client TLS unknownNative sockets; acceptance unknown
MessagingrabbitmqRabbitMQ / AMQPrabbitmq #github.com/xulang-org/packages/rabbitmqAPI ReferenceAMQP 0-9-1 subsetSASL PLAINTLS byte-stream helper; client TLS unknownNative sockets; acceptance unknown
MessagingnatsNATS High Throughputnats #github.com/xulang-org/packages/natsAPI ReferenceNATS text protocolUser / password CONNECTTLS byte-stream helper; client TLS unknownNative sockets; acceptance unknown
MessagingmqttMQTT IoT Protocolmqtt #github.com/xulang-org/packages/mqttAPI ReferenceMQTT 3.1.1; QoS 0 / 1CONNECT username / passwordTLS byte-stream helper; client TLS unknownNative sockets; acceptance unknown
Coordinationetcdetcd v3 Distributed KVetcd #github.com/xulang-org/packages/etcdAPI Referencev3 HTTP/JSON gateway; not native gRPCunknownHTTPS request path; fd pools remain plaintextNative sockets; acceptance unknown
CoordinationconsulHashiCorp Consulconsul #github.com/xulang-org/packages/consulAPI ReferenceHTTP APIX-Consul-Token headerHTTPS request path; fd pools remain plaintextNative sockets; acceptance unknown
CoordinationzookeeperApache ZooKeeperzookeeper #github.com/xulang-org/packages/zookeeperAPI ReferenceFour-letter admin commands; not a session clientunknownTLS byte-stream helper; client TLS unknownNative sockets; acceptance unknown
CoordinationnacosAlibaba Nacosnacos #github.com/xulang-org/packages/nacosAPI ReferenceHTTP OpenAPI subsetunknownHTTPS request path; fd pools remain plaintextNative sockets; acceptance unknown
SearchelasticsearchElasticsearch / OpenSearchelasticsearch #github.com/xulang-org/packages/elasticsearchAPI ReferenceHTTP/JSON API subsetunknownHTTPS request path; fd pools remain plaintextNative sockets; acceptance unknown
SearchmeilisearchMeilisearch Enginemeilisearch #github.com/xulang-org/packages/meilisearchAPI ReferenceHTTP/JSON; integer document IDsBearer API keyHTTPS request path; fd pools remain plaintextNative sockets; acceptance unknown
ObservabilityprometheusPrometheus Metricsprometheus #github.com/xulang-org/packages/prometheusAPI ReferenceText metrics / HTTP PushgatewayunknownHTTPS request path; fd pools remain plaintextNative sockets; acceptance unknown
ObservabilityinfluxdbInfluxDB Time Seriesinfluxdb #github.com/xulang-org/packages/influxdbAPI ReferenceHTTP API / line protocolAuthorization: TokenHTTPS request path; fd pools remain plaintextNative sockets; acceptance unknown
Vectors & AImilvusMilvus Vector DBmilvus #github.com/xulang-org/packages/milvusAPI ReferenceREST v2 search; integer IDsBearer token fieldHTTPS request path; fd pools remain plaintextNative sockets; acceptance unknown
Vectors & AIqdrantQdrant Vector Engineqdrant #github.com/xulang-org/packages/qdrantAPI ReferenceHTTP/JSON API subsetapi-key headerHTTPS request path; fd pools remain plaintextNative sockets; acceptance unknown
Vectors & AIchromaChroma Embeddings DBchroma #github.com/xulang-org/packages/chromaAPI ReferenceHTTP/JSON API subsetunknownHTTPS request path; fd pools remain plaintextNative sockets; acceptance unknown
Storages3AWS S3 / MinIO Protocols3 #github.com/xulang-org/packages/s3API ReferenceS3 HTTP object API subsetAWS SigV4HTTPS request path; fd pools remain plaintextNative sockets; acceptance unknown
ProtocolsgrpcgRPC / HTTP/2 Clientgrpc #github.com/xulang-org/packages/grpcAPI ReferenceHTTP/2 unary; no streaming / compressionunknownHTTPS unary with ALPN h2; fd pool is h2cNative sockets; acceptance unknown
ProtocolswebsocketWebSocket Full-Duplexwebsocket #github.com/xulang-org/packages/websocketAPI ReferenceHTTP Upgrade / WebSocket framesunknownwss via connect_secure; retain transport.ConnNative sockets; acceptance unknown
ProtocolsdnsDNS Custom Resolverdns #github.com/xulang-org/packages/dnsAPI ReferenceTCP DNS A-record queries; not UDPunknownTLS byte-stream helper; client TLS unknownNative sockets; acceptance unknown
ProtocolssmtpSMTP Mail Deliverysmtp #github.com/xulang-org/packages/smtpAPI ReferenceSMTP mail deliveryAUTH LOGINTLS byte-stream helper; client TLS unknownNative sockets; acceptance unknown
Shared transporttransportTCP / TLS / HTTP framingtransport #github.com/xulang-org/packages/transportAPI ReferenceTCP / TLS; HTTP/1.x response framingApplication-level authentication unknowncrypto/tls via dial; custom tls.ConfigNative sockets; acceptance unknown
AI APIsopenaiOpenAI-Compatible LLM APIsopenai #github.com/xulang-org/packages/openaiAPI ReferenceChat, Responses, Files, Batches, Audio, Images & EmbeddingsBearer API keyHTTPS via #net/httpNative sockets; acceptance unknown
AI APIsanthropicAnthropic Messages APIanthropic #github.com/xulang-org/packages/anthropicAPI Reference/v1/messages sync, SSE streaming, tools & visionx-api-key headerHTTPS via #net/httpNative sockets; acceptance unknown
AI APIsgeminiGoogle Gemini APIgemini #github.com/xulang-org/packages/geminiAPI ReferencegenerateContent, streamGenerateContent SSE & embedContentx-goog-api-key headerHTTPS via #net/httpNative sockets; acceptance unknown
AI APIscohereCohere v2 Chat / Embed / Rerankcohere #github.com/xulang-org/packages/cohereAPI Reference/v2/chat, /v2/embed & /v2/rerankBearer API keyHTTPS via #net/httpNative sockets; acceptance unknown
AI OrchestrationgatewayMulti-Provider LLM Gatewaygateway #github.com/xulang-org/packages/gatewayAPI ReferenceFailover, weighted routing, semantic cache & Redis stateDelegates to configured provider clientsDelegates to configured provider clientsNative sockets / Redis; acceptance unknown
AI ProtocolsmcpModel Context Protocol (2025-03-26)mcp #github.com/xulang-org/packages/mcpAPI ReferenceJSON-RPC 2.0 stdio & Streamable HTTP server / clientOptional Bearer token / custom headersHTTPS for remote endpoints; local stdio / HTTP serverNative sockets / stdio; acceptance unknown
AI Protocolsa2aAgent-to-Agent (A2A) Protocola2a #github.com/xulang-org/packages/a2aAPI ReferenceAgentCard discovery, JSON-RPC 2.0 & tasks/sendSubscribe SSEServer auth unknownClient via #net/http; built-in server is plaintext HTTPNative sockets; acceptance unknown
AI OrchestrationagentTool / Swarm / StateGraph Runtimeagent #github.com/xulang-org/packages/agentAPI ReferenceMulti-turn tools, AgentSwarm, HITL StateGraph & SKILL.mdDelegates to configured provider clientsDelegates to configured provider clientsLocal SDK runtime; acceptance unknown
AI ToolingpromptPrompt Templates & Few-Shotprompt #github.com/xulang-org/packages/promptAPI ReferencePromptRegistry rendering, #tensor few-shot & JSON extractionNot applicable (local library)Not applicable (no network transport)Local SDK library; acceptance unknown
AI SafetyguardrailsGuardrails & PII / Injection Filtersguardrails #github.com/xulang-org/packages/guardrailsAPI ReferencePII redaction, injection/leak checks & optional model safetyOptional OpenAI client delegationOptional HTTPS via OpenAI client; local otherwiseLocal SDK library; acceptance unknown
AI EvaluationevalLLM & RAG Evaluation Suiteseval #github.com/xulang-org/packages/evalAPI ReferenceBLEU/ROUGE/F1, Ragas Triad, calibration & LLM-as-JudgeOptional judge client delegationOptional HTTPS via judge client; local otherwiseLocal SDK library; acceptance unknown
Vectors & AIragHybrid & GraphRAG Retrievalrag #github.com/xulang-org/packages/ragAPI ReferencePgVectorClient, SqliteVectorStore, QdrantVectorStore & GraphRAGDelegates to postgres / qdrant / provider clientsDelegates to postgres / qdrant / provider clientsLocal SDK / native sockets; acceptance unknown
AI DatasynthSynthetic SFT / DPO / RLVR Datasetssynth #github.com/xulang-org/packages/synthAPI ReferenceSFT/DPO generation, distillation, dedup & JSONL exportDelegates to configured OpenAI clientDelegates to configured OpenAI clientLocal SDK / native sockets; acceptance unknown
GPU ComputegpuUnified GPU Backend Facadegpu #github.com/xulang-org/packages/gpuAPI ReferenceBackend selection over Metal / CUDA / VulkanNot applicable (local GPU)Not applicable (no network transport)Native GPU FFI; target acceptance unknown
GPU Computellm_metalMetal GPU LLM K-Quant GEMVllm_metal #github.com/xulang-org/packages/llm_metalAPI ReferenceApple Silicon Metal K-quant SIMD GEMV inference kernelsNot applicable (local GPU)Not applicable (no network transport)Apple Silicon macOS Metal FFI; target acceptance unknown
GPU Computecuda_nativeNVIDIA CUDA Native Bindingscuda_native #github.com/xulang-org/packages/cuda_nativeAPI ReferencePure-Xu dlopen CUDA runtime & kernel dispatchNot applicable (local GPU)Not applicable (no network transport)Native CUDA FFI; target acceptance unknown
GPU Computevulkan_nativeVulkan SPIR-V Compute Bindingsvulkan_native #github.com/xulang-org/packages/vulkan_nativeAPI ReferencePure-Xu dlopen Vulkan compute & SPIR-V shadersNot applicable (local GPU)Not applicable (no network transport)Native Vulkan FFI; target acceptance unknown

5. Boundaries & Production Builds

For more details on MVS resolution, checksum verification, and private proxies, see: Modules and Dependencies Specification and Native Modules Specification.

AI Packages & Multi-Backend GPU Compute (v1.17.0 · 50 packages)

Alongside the 30 packages bundled with the SDK, the standalone github.com/xulang-org/packages repository (v1.17.0, 50 packages total) adds pure-Xu AI, agent, protocol, and multi-backend GPU packages organized across four areas:

1. Multi-Backend GPU & Local GPU LLM Inference

PackageImport PathCapabilities
gpugpu #github.com/xulang-org/packages/gpuUnified GPU facade (BACKEND_METAL / CUDA / VULKAN / CPU) with detect_backends, open_auto, open_backend, and unified matrix ops
llm_metalllm_metal #github.com/xulang-org/packages/llm_metalEnd-to-end Apple Silicon GPU Transformer engine: load_gguf / load_safetensors / load_model, MetalKVCache / MetalPagedKVCache, generate_paged, and MetalLoRA (train_lora_step)
metal / metal_nativemetal #github.com/xulang-org/packages/metal176 Metal GPU symbols: F32/F16/Q4–Q6KMatrix (up to 262,144 dim), Metal K-quant SIMD GEMV, FlashAttention/FlashDecode, PagedAttention F16, MoE & LoRA backprop
cuda_nativecuda_native #github.com/xulang-org/packages/cuda_nativePure-Xu dlopen loader for CUDA Driver API, NVRTC, and cuBLAS (XU_CUDA_LIBRARY overrides, zero C wrapper)
vulkan_nativevulkan_native #github.com/xulang-org/packages/vulkan_nativePure-Xu dlopen Vulkan 1.1 compute pipelines + pure-Xu SPIR-V 1.0 generator (spirv.xu) across Linux, Windows, and MoltenVK

2. LLM Clients, Heterogeneous Gateway & Prompts

PackageImport PathCapabilities
openaiopenai #github.com/xulang-org/packages/openai11 presets (DeepSeek, OpenRouter, Groq, Qwen, Mistral, MiniMax, etc.), Chat/Responses API, Files/Batches, Whisper/TTS, Images & Rerank
anthropicanthropic #github.com/xulang-org/packages/anthropicMessages API (/v1/messages), Prompt Caching, extended thinking, vision blocks, and chunked tool_use SSE merging
geminigemini #github.com/xulang-org/packages/geminiGemini REST (generate* / streamGenerateContent?alt=sse), response_schema_json, thinking_budget, and batchEmbedContents
coherecohere #github.com/xulang-org/packages/cohereNative Cohere v2 client (chat, float embed, and rerank)
gatewaygateway #github.com/xulang-org/packages/gatewayCross-provider (OpenAI/Anthropic/Gemini) weighted routing & sync/SSE failover, circuit breakers & RPM limits, ProviderPassthrough, cost tracking, and Redis distributed state (set_redis_pool / set_redis_url)
promptprompt #github.com/xulang-org/packages/promptVersioned PromptRegistry, #tensor dynamic few-shot selection, and Markdown JSON block extraction

3. Agents, Open Protocols & RAG Retrieval

PackageImport PathCapabilities
agentagent #github.com/xulang-org/packages/agent4-runtime parity (OpenAI Chat/Responses, Anthropic, Gemini), cross-provider AgentSwarm, pluggable set_token_counter, SQLite memory/session/graph checkpoints, SKILL.md skills, parallel HITL StateGraph, and OTLP/Prometheus tracing
mcpmcp #github.com/xulang-org/packages/mcpModel Context Protocol JSON-RPC 2.0 (2025-03-26) bidirectional stdio & Streamable HTTP servers/clients and SSE negotiation
a2aa2a #github.com/xulang-org/packages/a2aAgentCard discovery, JSON-RPC 2.0 tasks, live SSE tasks/sendSubscribe, plus API Key / hook auth and SQLite task storage (v1.16.0)
ragrag #github.com/xulang-org/packages/ragPooled PgVectorPool (v1.16.0), PgVectorClient, cached persistent SqliteVectorStore (cached_len / refresh_cache), QdrantVectorStore, automated GraphRAG KnowledgeGraph, and chunking/rerank pipelines

4. Guardrails, Evaluation & Synthetic Data

PackageImport PathCapabilities
guardrailsguardrails #github.com/xulang-org/packages/guardrailsPII/secret redaction, prompt injection & canary leak guards, RAG sanitization, check_safety_openai, and strict_policy / normalize_for_detection / check_input_strict (v1.16.0)
evaleval #github.com/xulang-org/packages/evalexact_match, F1, ROUGE, BLEU, evaluate_json_schema_raw JSON Schema checks, pass_at_k, ECE, Ragas Triad & LLM-as-a-Judge regression gating
synthsynth #github.com/xulang-org/packages/synthSFT/DPO/RLVR generation & distillation, exact & Jaccard n-gram deduplication, quality filters, and llm_engine JSONL export

AI Package & Driver Known Boundaries

Production checklist: The following boundaries describe the Xu v0.15.0 and packages v1.17.0 source; configure reverse proxies, external stores, or model checks accordingly before production rollout.

Build the Metal native library (optional macOS)

Applications that do not import metal, llm_metal, or the Metal backend do not need to build Metal native assets. Before using Metal GPU compute on Apple Silicon macOS, build its shared dynamic library:

cd packages
python3 metal/native/build.py