library CB-Action;
fn CB-Action.ready(u256 frame, u256 cooldownFrames, u256 lastFrame) -> bool {
return frame >= lastFrame + cooldownFrames;
}
fn CB-Action.force_passes(f64 incomingForce, f64 threshold) -> bool {
return incomingForce >= threshold;
}
fn CB-Action.triggered(bool input, f64 incomingForce, f64 threshold, i256 health) -> bool {
if (input) { return true; }
if (incomingForce >= threshold) { return true; }
return health <= 0;
}
Source browser
Open a library and copy the code.
Usage docs explain how to call libraries; this page shows the actual `.cbp` source files.
Coding Suite libraries 72
Developer recipes
What a dev can reasonably build with these libraries.
Use these as starting points when choosing a library. Each recipe maps to source files and examples on this page.
Local tool API
Use `CB-Networking.API` to match `method + path`, verify a bearer token, and return structured ClosedBit responses for launchers, local tools, and test harnesses.
External service call
Use `CB-Networking.HTTP.get_or()` for a runtime-backed GET with an offline fallback, then inspect the response with string helpers before continuing.
Save and reload app state
Use `CB-Storage` for validated `.cb` saves and `CB-AssetLoader` for files the app ships with, keeping mutable save data separate from bundled assets.
Indexed AI retrieval
Use `CB-GenerationOptimized` with `CB-Parsing` and `CB-Understanding` when the app needs tagged retrieval instead of brute-force text scanning.
Source locations
Every Coding Studio library source file.
The website mirrors the same `.cbp` files installed with ClosedBit Coding Studio, so developers can inspect the callable surface before building.
Installed source browser: ClosedBit Studio > Docs > Libraries
Website mirror: /docs/libraries/source/studio/
Coding Suite libraries:
CB-Action.cbp
CB-AI.Heuristics.cbp
CB-AI.Pattern.cbp
CB-AI.Search.cbp
CB-AssetLoader.cbp
CB-Audio.cbp
CB-Bit.cbp
CB-Breakable.cbp
CB-Cache.Local.cbp
CB-Console.cbp
CB-Data.cbp
CB-Data.CSV.cbp
CB-Data.TOML.cbp
CB-Data.XML.cbp
CB-Data.YAML.cbp
CB-Database.Local.cbp
CB-FileSystem.Path.cbp
CB-FileSystem.Storage.cbp
CB-FileSystem.Watch.cbp
CB-Generation.cbp
CB-Generation.Image.cbp
CB-Generation.Response.cbp
CB-Generation.Text.cbp
CB-GenerationOptimized.cbp
CB-GPU.cbp
CB-Graphics.2D.cbp
CB-Graphics.3D.cbp
CB-Graphics.Font.cbp
CB-Library.Compression.cbp
CB-Library.Config.cbp
CB-Library.Cryptography.cbp
CB-Library.DataStructures.cbp
CB-Library.Logging.cbp
CB-Library.Serialization.cbp
CB-Library.Testing.cbp
CB-Library.Validation.cbp
CB-Math.Basic.cbp
CB-Math.cbp
CB-Math.Linear.cbp
CB-Math.Random.cbp
CB-Multimedia.Audio.cbp
CB-Multimedia.Image.cbp
CB-Multimedia.Video.cbp
CB-Network.cbp
CB-Networking.API.cbp
CB-Networking.DNS.cbp
CB-Networking.HTTP.cbp
CB-Networking.Socket.cbp
CB-Networking.WebSocket.cbp
CB-Parsing.cbp
CB-Pathfinding.cbp
CB-Physics.cbp
CB-Render.cbp
CB-Runtime.cbp
CB-Security.Auth.cbp
CB-Security.RateLimit.cbp
CB-Security.RBAC.cbp
CB-Shader.cbp
CB-Storage.cbp
CB-System.Env.cbp
CB-System.OS.cbp
CB-System.Timer.cbp
CB-TextToSpeech.cbp
CB-TextToSpeech.Voices.cbp
CB-Time.cbp
CB-Time.Scheduler.cbp
CB-UI.cbp
CB-Understanding.cbp
CB-Understanding.Image.cbp
CB-Understanding.Language.cbp
CB-Understanding.Logic.cbp
Examples
Copy-paste library examples. 93
These are real mirrored `.cbp` examples from the shipped example tree. Open the full examples index, or copy the starter blocks below into Studio.
library CB-Console;
library CB-Networking.API;
library CB-Networking.HTTP;
fn main() {
string requestMethod = "GET";
string requestPath = "/support/status";
string expectedToken = "dev-token";
string authHeader = CB-Networking.HTTP.bearer(expectedToken);
bool routeOk = CB-Networking.API.match(requestMethod, requestPath, "GET", "/support/status");
bool authOk = CB-Networking.API.require_token(authHeader, expectedToken);
if (!routeOk) {
println(CB-Networking.API.error(404, "route not found"));
return;
}
if (!authOk) {
println(CB-Networking.API.error(401, "missing or invalid token"));
return;
}
string body = "support=online;queue=2;priority=normal";
println("Route: " + CB-Networking.API.route(requestMethod, requestPath));
println("Response: " + CB-Networking.API.ok(body));
}
Teaches: route matching, bearer-token checks, 404/401 fallbacks, and success responses for local API-style handlers.
library CB-Console;
library CB-Networking.HTTP;
fn main() {
string base = "https://closedbit.com";
string url = CB-Networking.HTTP.endpoint(base, "/sitemap.xml");
string fallback = "offline=true;source=fallback";
string response = CB-Networking.HTTP.get_or(url, fallback);
println("Request: " + CB-Networking.HTTP.cache_key("GET", url));
println("Header: " + CB-Networking.HTTP.accept("application/xml"));
println("Characters: " + len(response));
if (string.contains(response, "<urlset")) {
println("Connected: sitemap loaded");
} else {
println("Fallback: " + response);
}
}
Teaches: endpoint joining, a real runtime-backed GET, offline fallback handling, request labeling, and response inspection.
library CB-Console;
library CB-Storage;
fn main() {
string path = "closedbit-player-save.cb";
string initial = "player=Ada;score=1250;level=4";
CB-Storage.write_text(path, initial);
string loaded = CB-Storage.read_text(path);
println("ClosedBit Storage Round Trip");
println("Exists: " + CB-Storage.exists(path));
println("Loaded: " + loaded);
}
library CB-Console;
library CB-GenerationOptimized;
library CB-Parsing;
library CB-Understanding;
fn main() {
string dataset = "examples/ai/shared-mini-dataset.txt";
string index = "build/ai/shared-mini-dataset.cbi";
CB-GenerationOptimized.build_index(dataset, index);
u256 indexed = CB-GenerationOptimized.warm(index);
array batches = CB-GenerationOptimized.query_batch(dataset, index, ["ai,gpu", "game,gpu", "storage,index"], 3);
array records = batches[0];
string picked = CB-GenerationOptimized.pick(dataset, index, "game,gpu", 256);
println("ClosedBit Native Indexed Retrieval");
println("Retrieval backend: " + CB-GenerationOptimized.last_backend());
println("Indexed records: " + indexed);
println("Matches: " + records.length());
println("Picked: " + CB-Parsing.normalize(picked));
println("AI score: " + CB-Understanding.score(picked, "gpu"));
println("Native mapping hits: " + CB-GenerationOptimized.cache_hits());
println("Native mapping misses: " + CB-GenerationOptimized.cache_misses());
println("Native records scanned: " + CB-GenerationOptimized.records_scanned());
}
library CB-Console;
library CB-GPU;
fn main() {
println("ClosedBit temporary Direct3D 12 GPU status");
println("Available: " + CB-GPU.available());
println("Driver: " + CB-GPU.name());
println("Backend: " + CB-GPU.backend());
println("VRAM visible MB: " + CB-GPU.vram_total_mb());
println("Policy cap MB: " + CB-GPU.budget_mb());
}
library CB-Library;
library CB-Library.Graphics;
library CB-Library.Threaded;
library CB-Render;
library CB-Runtime;
fn main() {
init_window(960, 540, "ClosedBit Runtime Memory Cleanup");
set_background_color(0x071019);
CB-Render.starfield(8_000, 1, 0xD7F9FF);
CB-Render.particles(2_500, 1, 0x48D1CC, 0xFFBE55);
CB-Render.cube_field(64, 1, 0x83E8FF);
CB-Render.flush();
println("Renderer before cleanup: " + CB-Render.backend());
cleanup();
array memory = CB-Runtime.cleanup_memory();
println("Working set bytes: " + memory[0] + " -> " + memory[1]);
println("Pageable committed bytes: " + memory[2] + " -> " + memory[3]);
println("Private bytes: " + memory[4] + " -> " + memory[5]);
println("Cleanup page faults: " + (memory[7] - memory[6]));
u256 reuse_faults_before = CB-Runtime.page_fault_count();
CB-Runtime.raw_kernel(2_000_000, 256);
println("Hot reuse page faults: " + (CB-Runtime.page_fault_count() - reuse_faults_before));
}
All mirrored examples
Every link below opens a real `.cbp` example file under `/docs/libraries/examples/`.
ai (7)
apps (15)
- apps/ai_capacity_planner.cbp
- apps/ai_content_tool.cbp
- apps/bitflag_editor.cbp
- apps/calculator.cbp
- apps/expense_tracker.cbp
- apps/fallbacks.cbp
- apps/guessing_game.cbp
- apps/inventory_game.cbp
- apps/math_kernel.cbp
- apps/native_ui_counter.cbp
- apps/physics_integrator.cbp
- apps/runtime_probe.cbp
- apps/storage_roundtrip.cbp
- apps/text_analyzer.cbp
- apps/ui_dashboard.cbp
benchmarks (10)
- benchmarks/direct3d_render_batch.cbp
- benchmarks/fps_fixed_overhead_long.cbp
- benchmarks/fps_fixed_overhead.cbp
- benchmarks/fps_physics_swarm_steady.cbp
- benchmarks/math_kernel.cbp
- benchmarks/physics_integrator.cbp
- benchmarks/runtime_layer.cbp
- benchmarks/runtime_memory_cleanup.cbp
- benchmarks/runtime_usage_study.cbp
- benchmarks/wide_math_kernel.cbp
cbp (16)
complete (21)
- complete/ai_generation_parsing.cbp
- complete/arrays_strings.cbp
- complete/bit_data_math.cbp
- complete/console_types_pemdas.cbp
- complete/control_flow.cbp
- complete/direct3d_render_batch.cbp
- complete/everyday_runtime_helpers.cbp
- complete/functions_namespaces.cbp
- complete/html_ui.cbp
- complete/large_loop_guard.cbp
- complete/native_ui_drawing.cbp
- complete/ordinary_text_files.cbp
- complete/parallel_physics_world.cbp
- complete/random_time.cbp
- complete/runtime_memory_cleanup.cbp
- complete/runtime_profiles_threading.cbp
- complete/runtime_resource_budget.cbp
- complete/safe_errors.cbp
- complete/threaded_graphics_bulk.cbp
- complete/uncapped_profile.cbp
- complete/validated_cb_saving.cbp
external-physics (1)
games (17)
- games/asteroid_drift.cbp
- games/brick_breaker.cbp
- games/combat_arena.cbp
- games/cube_flight.cbp
- games/dungeon_dash.cbp
- games/first_person_shooter.cbp
- games/lane_racer.cbp
- games/neon_pong.cbp
- games/particle_arena.cbp
- games/physics_swarm.cbp
- games/platform_hopper.cbp
- games/pong.cbp
- games/safety_recovery.cbp
- games/saved_starfield.cbp
- games/snake_grid.cbp
- games/space_defender.cbp
- games/tower_guard.cbp